Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //open database
- include_once 'connectToDataBase.php';
- $query = "SELECT ProductID, Product_Name, Price, Product_Picture FROM products LIMIT 9 WHERE mostWanted = 1 ORDER BY Price DESC ";
- if (!($stmt = $PhpToDatabaseConnection->prepare($query))) {
- echo "Prepare failed: (" . $PhpToDatabaseConnection->errno . ") " . $PhpToDatabaseConnection->error;
- }
- //RUN SELECT QUERY
- if (!$stmt->execute()) {
- echo "Execute failed: (" . $PhpToDatabaseConnection->errno . ") " . $PhpToDatabaseConnection->error;
- }
- //READY SELECT VARIABLES
- $out_id = NULL;
- $out_title = NULL;
- $out_price = NULL;
- $out_image = NULL;
- //BIND SELECT VARIABLES
- if (!$stmt->bind_result($out_id, $out_title, $out_price, $out_image)) {
- echo "Binding output parameters failed: (" . $stmt->errno . ") " . $stmt->error;
- }
- //PREPARE HTML HANDLING
- $item_open = '<div class="inside-items"><div class="shop-item">';
- $item_stop = '</div></div>';
- //START LINE
- while ($stmt->fetch()) {
- //START NEW ITEM
- echo $item_open;
- echo '<img class="shop-item-picture" src="', $out_image ,'">';
- echo '<div class="shop-item-title">', $out_title ,'</div>';
- echo '<div class="fancy-line-5"></div>';
- echo '<div class="shop-item-price">Price: £', $out_price ,'</div>';
- echo '<div class="shop-item-button"><a class="productLink" href="product.php?id=', $out_id ,'">Add to Cart</a></div>';
- //END LAST ITEM
- echo $item_stop;
- }
- //END LAST LINE
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement