Advertisement
Guest User

Untitled

a guest
Sep 11th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. <?php
  2. $user = $r['username'];
  3. $servername = "***";
  4. $username = "***";
  5. $password = "***";
  6. $dbname = "***";
  7.  
  8. // Create connection
  9. $conn = new mysqli($servername, $username, $password, $dbname);
  10. // Check connection
  11. if ($conn->connect_error) {
  12. die("Connection failed: " . $conn->connect_error);
  13. }
  14.  
  15. $sql = "SELECT * FROM Wishlist WHERE User = '$user' ORDER BY Id ASC";
  16. $result = $conn->query($sql);
  17.  
  18. if ($result->num_rows > 0) {
  19. // output data of each row
  20. while($row = $result->fetch_assoc()) {
  21. echo "<b>";
  22. echo $row['Name'];
  23. echo "</b><br>$";
  24. echo $row['Price'];
  25. echo "<br>";
  26. echo "<form method='post' action='wish2.php'>
  27. <input type='hidden' name='name' value='";
  28. echo $row['Name'];
  29. echo "'><input type='hidden' name='price' value='";
  30. echo $row['Price'];
  31. echo "'><input type='hidden' name='user' value='";
  32. echo $row['User'];
  33. echo "'><input type='submit' value='Bought this item'></form><br>";
  34. echo "<form method='post' action='remove.php'><input type='hidden' name='user' value='";
  35. echo $row['User'];
  36. echo "'><input type='hidden' name='item' value='";
  37. echo $row['Name'];
  38. echo "'><input type='submit' value='Remove the item from wishlist'></form>";
  39. echo "<hr>";
  40. }
  41. } else {
  42. echo "No items found in your wishlist!";
  43. }
  44. $conn->close();
  45. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement