title: How to code an "Add to Cart" at the end of each row that ONLY adds THAT item to cart?
body: <p>I'm displaying a list of books on a table from my database, I want to add an 'Add to Cart' button at the end of each row. I'm having trouble finding out how can I distinguish each row so that the "Add to Cart" of row #2 only adds the book in row #2 to user's cart.</p>
  
  <p>Something like this: <a href="https://i.stack.imgur.com/XcwoP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XcwoP.png" alt="enter image description here"></a></p>
  
  <p>This is the PHP for my search page:</p>
  
  <pre><code>&lt;?php
          if(isset($_POST['submit-search'])){
             $search = mysqli_real_escape_string($db, $_POST['search']);
             $sql = "SELECT * FROM books WHERE title LIKE '%$search%' OR author LIKE '%$search%' OR rdate LIKE '%$search%'";
             $result = mysqli_query($db, $sql);
             $queryResult = mysqli_num_rows($result);
             if($queryResult &gt; 0){
                 while($row = mysqli_fetch_assoc($result)){
                    echo "
  
                    &lt;tr&gt;
                    &lt;td&gt;".$row['title']."&lt;/td&gt;
                    &lt;td&gt;".$row['author']."&lt;/td&gt;
                    &lt;td&gt;".$row['rdate']."&lt;/td&gt;
                    &lt;td&gt;&lt;a class='cartbtn' href='cart.php?id=".$_SESSION['username']."'&gt;Add to Cart&lt;/a&gt;&lt;/td&gt;
                    &lt;/tr&gt;";
                 }
             } else {
              echo "There are no results matching your search";
             }
          }
      ?&gt;
  </code></pre>
  
  <p>Once the user clicks Add to Cart, I want to transfer him to a page "cart.php" where he can see all the items in his cart and maybe even be able to delete them, but that's for later - for now, I would really like some guidance on how I can indicate the "Add to Cart" button to only add the book that the user wants in his cart and not all of them. I apologize in advance if my question comes off as vague and not-so-transparent.</p>