This repository has been archived by the owner on Jan 7, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathfeatured.php
74 lines (67 loc) · 2.17 KB
/
featured.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
require ('./includes/config.inc.php');
require (MYSQL);
include ('./includes/header.php');
?>
<div id="home2">
<div class="grid_12">
<p><a href="home.php">Home</a> > <a class="current" href="featured.php">Featured Items</a></p>
<?php echo searchBar(); ?>
</div>
<div class="grid_2">
<div id="sidenav">
<ul>
<?php
$result = mysqli_query ($dbc, "SELECT * FROM categories ORDER by name;");
$categories_rows = array();
while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC))
{
array_push($categories_rows, $row);
$categoryLink = '<a href="catalog.php?category='.$row['id'].'">';
echo '<li>'.$categoryLink.$row['name'].'</a></li>';
}
?>
</ul>
</div>
</div>
<?php
$result = mysqli_query ($dbc, "SELECT * FROM products WHERE is_featured=1 ORDER by name;");
while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC))
{
$productPrice = $row['price'];
$productLink = '<a href="product.php?product_id='.$row['id'].'">';
$productName = $row['name'];
$productBrand = $row['brand'];
?>
<div class="grid_3">
<div class="item">
<h1><?php echo $productLink ?></a><?php echo $productName ?></h1>
<h2><?php echo $productBrand ?></h2>
<?php echo $productLink ?><img src="img/<?php echo imageSmall($row['image']) ?>" alt="<?php echo $productName ?>" /></a>
<?php
$salePrice = productIsOnSale($dbc, $row['id']);
// On sale display sale price
if ($salePrice) {
echo "<h4 class=\"sale\">Price: $productPrice</h4>";
echo "<h3 class=\"sale\">SALE: $salePrice</h3>";
}
else {
echo "<br /><br /><br /><h3>Price: $productPrice</h3>";
}
?>
</div>
</div>
<?php
}
?>
<!-- <div class="grid_3">
<div class="item">
<h1><a href="art1.php">Jumbo Chalk</a></h1>
<h2>Melissa & Doug</h2>
<a href="art1.php"><img src="img/item2a.png" alt="jumbo chalk" /></a>
<h4>Price: $2.55</h4>
<h3>SALE: $2.00</h3>
</div>
</div> -->
</div>
<?php include ('./includes/footer.php'); ?>