A
A
Artem2020-05-17 18:57:48
PHP
Artem, 2020-05-17 18:57:48

How to hide a form by defining a user and their selection?

Items have ratings. The user can vote, but the rating remains visible. After voting, the rating should be locked so that the user does not vote again. From the form I pass the values ​​'stars_id' 'cookie' 'val' to the table using ajax. How to do data validation and select input to close?

$ra1 = $row['rating']; 
    $checked = intval($ra1); 
    $count = 5; 
    $inputs = '';
    for($i = 1; $i <= $count; $i++) { 
    $checked_attr = $i == $checked ? ' checked' : '';
    $inputs .= '<input  class="rating-input" id="mod' . $i . '' . $row["products_id"] . '" star-attr="' . $row["products_id"] . '" name="radio-rating" type="radio" value="' . $i . '"' . $checked_attr . '>';
    $inputs .= '<label class="rating-star" for="mod' . $i . '' . $row["products_id"] . '" ></label>';
    };

    // вывод
    echo '
    <div  class="order_right">  
     <div  class="wrap_stars">
      <form class="form-rating" method="POST">
      <fieldset class="fieldset">
      <legend></legend>
      <div class="rating-group">

       ' .$inputs . '
      
       </div>
      </fieldset>
        <div class="count_block">
        <!-- Статистика -->
        <ul class="count" >' . $row["rating"] . '</ul>
        </div>
       </form>
      </div>
    </div>

5ec15e9c19146669669018.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Reut, 2020-05-18
@ArduinoFlow

I'm not a guru, of course, but if you create an array and enter the user ID there, and then compare them?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question