-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathproduct_item2.php
34 lines (32 loc) · 1.42 KB
/
product_item2.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
<?php include __DIR__ . '/__connect_db.php';
if (isset($_GET['animal'])) {
$animal = isset($_GET['animal']) ? $_GET['animal'] : '';
$sql = "SELECT * FROM `products` WHERE `animal`= '$animal'";
} else {
$mottotype = isset($_GET['mottotype']) ? $_GET['mottotype'] : '';
$sql = "SELECT * FROM `products` WHERE `mottotype`= '$mottotype'";
}
$result = $mysqli->query($sql);
?>
<?php
while ($row = $result->fetch_assoc()): ?>
<div class="one_product production_item" id="<?= $row['sid'] ?>">
<div class="one_product_img production_link" data-sid="<?= $row['sid'] ?>" style="background-image:url(<?= $row['pic_id'] ?>00.png);">
</div>
<div class="one_product_info">
<p class="product_name"><?= $row['productname'] ?></p>
<p class="product_motto"><?= $row['motto'] === '1' ? '' : $row['motto'] ?></p>
<div class="product_price">NT <?= $row['price'] ?></div>
<div class="add_to_cart production_link" data-sid="<?= $row['sid'] ?>"></div>
<div class="add_to_love"></div>
</div>
</div>
<script>
$('.one_product_img.production_link').click(function () {
location.href = 'single_product.php?sid=' + $(this).attr('data-sid');
})
$('.add_to_cart.production_link').click(function () {
location.href = 'single_product.php?sid=' + $(this).attr('data-sid');
})
</script>
<?php endwhile; ?>