Advertisement
Guest User

Untitled

a guest
May 20th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.44 KB | None | 0 0
  1. <?php
  2. //open database
  3. include_once 'connectToDataBase.php';
  4.  
  5. $query = "SELECT ProductID, Product_Name, Price, Product_Picture FROM products LIMIT 9 WHERE mostWanted = 1 ORDER BY Price DESC ";
  6.  
  7.  
  8. if (!($stmt = $PhpToDatabaseConnection->prepare($query))) {
  9.     echo "Prepare failed: (" . $PhpToDatabaseConnection->errno . ") " . $PhpToDatabaseConnection->error;
  10. }
  11.  
  12. //RUN SELECT QUERY
  13. if (!$stmt->execute()) {
  14.     echo "Execute failed: (" . $PhpToDatabaseConnection->errno . ") " . $PhpToDatabaseConnection->error;
  15. }
  16.  
  17. //READY SELECT VARIABLES
  18. $out_id    = NULL;
  19. $out_title = NULL;
  20. $out_price = NULL;
  21. $out_image = NULL;
  22.  
  23. //BIND SELECT VARIABLES
  24. if (!$stmt->bind_result($out_id, $out_title, $out_price, $out_image)) {
  25.     echo "Binding output parameters failed: (" . $stmt->errno . ") " . $stmt->error;
  26. }
  27.  
  28. //PREPARE HTML HANDLING
  29. $item_open = '<div class="inside-items"><div class="shop-item">';
  30. $item_stop = '</div></div>';
  31.  
  32.  
  33. //START LINE
  34. while ($stmt->fetch()) {
  35.     //START NEW ITEM
  36.     echo $item_open;
  37.     echo '<img class="shop-item-picture" src="', $out_image ,'">';
  38.     echo '<div class="shop-item-title">', $out_title ,'</div>';
  39.     echo '<div class="fancy-line-5"></div>';
  40.     echo '<div class="shop-item-price">Price: £', $out_price ,'</div>';
  41.     echo '<div class="shop-item-button"><a class="productLink" href="product.php?id=', $out_id ,'">Add to Cart</a></div>';
  42.     //END LAST ITEM
  43.     echo $item_stop;
  44. }
  45. //END LAST LINE
  46. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement