-
Notifications
You must be signed in to change notification settings - Fork 0
/
search-products-action.php
84 lines (71 loc) · 3.08 KB
/
search-products-action.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
<!DOCTYPE html>
<?php
// Start the session
session_start();
?>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Search Products - Action</title>
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600&display=swap" rel="stylesheet">
<link rel="stylesheet" href="assets/dist/css/bootstrap.min.css" >
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="vender/css/all.css">
</head>
<body>
<?php
if($_SESSION["username"] === ""){
echo $_SESSION['username'];
echo "login";
header("Location: index.php ");
}
?>
<div class="d-flex flex-column flex-md-row align-items-center p-3 px-md-4 mb-3 bg-white border-bottom shadow-sm">
<a class="navbar-brand my-0 mr-md-auto" href="dashboard.php">
<img src="images/logo.svg" alt="logo" width="130" height="30" alt="Logo" loading="lazy">
</a>
<button class="btn btn-outline logout-btn" onclick="location.href='user-logout.php'">Logout</button>
</div>
<div class="container h-100">
<div class="row align-items-center h-100" >
<div class="col-8 mx-auto">
<div class="mt-4">
<div class="text-center p-3">
<h3 class="theme-color">Search Result</h3>
</div>
</div>
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname ="inventory_db";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$product = filter_input(INPUT_GET,'query');
$sql="SELECT * FROM available_products_table WHERE product_id='$product' OR product_name='$product'";
$ret=mysqli_query($conn,$sql);
if(mysqli_num_rows($ret)>0)
{
echo"<table class='table table-striped'><thead><tr><th scope='col'>Product ID</th><th scope='col'>Product Name</th><th scope='col'>Product Price</th><th scope='col'>Quantity</th></tr></thead><tbody>";
while($row=mysqli_fetch_assoc($ret))
{
echo"<tr><th scope='row'>{$row['product_id']}</th><td>{$row['product_name']}</td><td>{$row['product_price']}</td><td>{$row['quantity']}</td></tr>";
}
echo"</tbody></table>";
echo"<form action='dashboard.php'><button type='submit' class='btn action-btn btn-block mt-4'>Done</button></form>";
}
if(mysqli_num_rows($ret)==0)
{
echo "<h3 class='text-center'>No such Products are thier....</h3><div class='col'><form action='dashboard.php'><button type='submit' class='btn action-btn btn-block mt-4'>Done</button></form></div>";
}?>
</div>
</div>
</div>
</body>
</html>