-
Notifications
You must be signed in to change notification settings - Fork 0
/
cloths_p.php
88 lines (76 loc) · 3.15 KB
/
cloths_p.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
session_start();
include("connect.php");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bid Bazzar</title>
<link href="https://cdn.jsdelivr.net/npm/remixicon@4.1.0/fonts/remixicon.css" rel="stylesheet" />
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
<link href="product.css" rel="stylesheet">
</head>
<body>
<Form action="" method="POST">
<?php include "navbar2.php"; ?>
<div id="load">
<?php
if (!isset($_SESSION['username'])) {
header("location:login.php");
}
$cat = "clothing";
// Query to select products from your database
$sql = "SELECT * FROM tbl_product WHERE category='$cat'";
if ($result = $connect->query($sql)) {
// Check if there are any products
if ($result->num_rows > 0) {
// Loop through each product and display its details
echo "<div class='products-container clearfix'>"; // Add clearfix to contain floated elements
$count = 0; // Initialize count for tracking products in the row
while ($row = $result->fetch_array()) {
if ($count % 3 == 0 && $count != 0) {
echo "<div class='clearfix'></div>"; // Clear float after every third product
}
echo "<a href='displayproduct.php?pids={$row["product_id"]}'><div class='product'>";
echo "<img src='" . $row['p_image'] . "' alt='" . $row['name'] . "'><br>";
echo "<h2>" . $row['p_name'] . "</h2>";
echo "<p>Price:" . $row['p_price'] . "</p>";
echo "</div></a>";
$count++; // Increment count for each product
}
echo "</div>"; // Close products container
// Free result set
$result->free();
} else {
echo "<p>No products found.</p>";
}
} else {
echo "<p>ERROR: Could not able to execute $sql. " . $mysqli->error . "</p>";
}
// Close connection
$connect->close();
?>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script>
$(document).ready(function() {
$("#search").on("keyup", function() {
var search_term = $(this).val();
$.ajax({
url: "ajax_cloth_serach.php",
type: "POST",
data: {
search: search_term
},
success: function(data) {
$("#load").html(data);
}
})
});
});
</script>
</Form>
</body>
</html>