-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmy_products.php
140 lines (121 loc) · 3.53 KB
/
my_products.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<!-- my_products.php -->
<?php
session_start();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My Products | CropConnect</title>
<link rel="icon" type="image/x-icon" href="images/cropconnect-favicon-color.ico">
<link rel="stylesheet" href="styles2.css">
<style>
.product-container {
margin-top: 20px;
text-align: center;
}
table {
width: 80%;
margin: 20px auto;
border-collapse: collapse;
}
th,
td {
border: 1px solid #ddd;
padding: 8px;
text-align: left;
}
th {
background-color: #f2f2f2;
}
.add-product-link {
display: block;
text-align: center;
margin-top: 20px;
font-size: 18px;
text-decoration: none;
color: #4CAF50;
}
</style>
</head>
<body>
<div class="navbar">
<a href="farmer_portal.php" class="logo"><img src="cropconnect.png" alt="Company Logo"></a>
<a href="farmer_portal.php">Home</a>
<a class="active" href="my_products.php">My Products</a>
<a href="transactions.php">Transactions</a>
<a href="support.php">Support</a>
<div class="login-container">
<?php
echo '<div class="login-name">Welcome ' . $_SESSION['firstName'] . '</div>';
?>
<a href="logout.php">Logout</a>
</div>
</div>
<div class="container product-container">
<h1>My Products</h1>
<a href="add_product.php" class="add-product-link">Add a New Product</a>
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "farmermarket";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT * FROM Product WHERE FarmerID = {$_SESSION['user_id']}";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
echo "<table>
<tr>
<th>Product Name</th>
<th>Category</th>
<th>Price</th>
<th>Stock</th>
</tr>";
while ($row = $result->fetch_assoc()) {
echo "<tr>
<td>{$row['ProductName']}</td>
<td>{$row['CatID']}</td>
<td>₹{$row['Price']}</td>
<td>{$row['Quantity_avail']}</td>
</tr>";
}
echo "</table>";
} else {
echo "You have no products listed.";
}
$conn->close();
?>
</div>
<br><br><br><br><br><br><br><br><br>
<div class="footer-content">
<div class="footer-section"></div>
<div class="footer-section">
<h4>Navigation</h4>
<p><a href="index.php">Home</a></p>
<p><a href="cart.php">Cart</a></p>
<p><a href="categories.php">Categories</a></p>
<p><a href="contact.php">Contact Us</a></p>
</div>
<div class="footer-section">
<h4>Address</h4>
<p>Jaypee Institute Of Information And Technology<br>
A-10, Sector-62, ,Noida-201 309,
Uttar Pradesh, India.
</p>
</div>
<div class="footer-section">
<h4>Contact</h4>
<p>Phone: +91 120-2400973</p>
</div>
<div class="footer-section">
<h4>Legal</h4>
<p><a href="terms.php">Terms and Conditions</a></p>
</div>
<div class="footer-section"></div>
</div>
</body>
</html>