title: 'Was this review helpful?' button PHP Jquery Ajax
body: <p>I am building a review system with php jquery and ajax. I have written the following code already for the 'Was this review helpful?' button:</p>
  
  <pre><code>&lt;input type='button' value='Yes' onClick = 'myCall()' 
         style='background-color:#556B2F;color:white;padding:2px; cursor:pointer'
         name='help' /&gt;
  &lt;input type='hidden' id='randomdirectory' value='$g' name='ids'/&gt;
  </code></pre>
  
  <p>$g is the variable I assigned to the id of the review which is stored in  a database. The ajax script is this:</p>
  
  <pre><code>&lt;script&gt;
  
  function myCall() {
  
  var ids = $('#randomdirectory').val(); 
  var self = this;
  
      $.ajax({
          url: 'rev.php',
          type: 'POST',
  
          data: {ids: ids},
           success: function(data) {
          $('#ques1').hide();
      }
  
      });
  
  }
  </code></pre>
  
  <p></p>
  
  <p>and the code in the "rev.php" file is this:</p>
  
  <pre><code>&lt;?php
  include 'includes/db.php';
  
  $q = $_POST['ids'];
  if ($q != ""){
  
  $result = mysql_query("SELECT * FROM table where id='$q'");
  
  while($row = mysql_fetch_array($result))
    {
    $finalproduct = $row['numberofhelpfulvotes'];
    $finalproduct1 = $finalproduct + 1;
  
  
    }
  
  
  mysql_query("UPDATE table SET numberofhelpfulvotes='$finalproduct1' WHERE id ='$q'");
  }
  
  ?&gt;
  </code></pre>
  
  <p>The problem is when I have multiple reviews on the page. When you click any of the "Yes" buttons on any of the reviews, the first review displayed gets the vote added to it, not the actual review where the button was clicked. Also when the button and text is hidden after the ajax call, the first review button and text is hidden, not the review where the button was clicked. Also a black line appears on the bottom of the page.</p>
  
  <p>Any solutions to these problems will be greatly appreciated.  </p>