-
Notifications
You must be signed in to change notification settings - Fork 2
/
display_items.php
193 lines (110 loc) · 3.47 KB
/
display_items.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="css/style.css">
<style type="text/css">
body{
background: radial-gradient(#fff,#ffd6d6);
}
h3{
color: red;
font-style: italic;
}
</style>
</head>
<body>
<?php
session_start();
if(!isset($_SESSION ["username"]))
{
header("Location:login.php");
}
else
{
$DBHOST = "localhost";
$DBUSER = "root";
$DBPWD = "";
$DBNAME = "Auction_table";
$conn = new mysqli($DBHOST, $DBUSER, $DBPWD, $DBNAME);
if($conn->connect_error)
{
die("Connection failed!".$conn->connect_error);
}
echo "<img id = 'logo' src = 'item/newauction.png' width='125px'>";
echo "<a href='logout.php' onclick='myFunction()' class = 'logout button'><button>Sign out</button></a>";
echo "Welcome, " . $_SESSION['username'] ;
echo "<script>
function myFunction() {
alert('Thank you for Coming, see you again!');
}
</script>
";
echo"<div class='container'>";
echo" <div class = 'navbar'>";
echo" <nav>";
echo" <ul>";
echo" <li><a href='add_item.php' class='submit' >Sell Product</a></li>";
echo" <li><a href='display_current.php'class='submit' >Ongoing</a></li>";
echo" <li><a href='displayfuture.php' class='submit'>Future Bids</a></li>";
echo" <li><a href='displayold.php' class='submit'>Expired Bids</a></li>";
echo"<li><a href='passwd_reset.php' class='submit'>Change password</a></li>";
echo"</ul>";
echo"</nav>";
echo"</div>";
echo" </div>";
echo "<br>";
$username = $_SESSION["username"];
$statement = "SELECT * FROM item ";
$result = $conn->query($statement);
while($row = $result->fetch_assoc())
{
$iid = $row["item_id"];
$iname = $row["item_name"];
$ipic = $row["item_pic"];
$starttime = $row["starttime"];
$end = $row["endtime"];
$reserve_price = $row["reserve_price"];
$icurrentp = $row["current_bid"];
$bid_num = $row["bid_num"];
$iimg = "item/";
$iimg = $iimg.$row["item_pic"];
$i_desc = $row["item_desc"];
$payment_method = $row["payment_method"];
$product_seller = $row["product_seller"];
$link = "item_details.php?item_id=";
$item_details = $link.$iid;
echo "<div class = 'item'>";
echo "<div class = 'item_row'>Product Id : $iid</div>";
echo "<br>";
echo "<div class = 'item_row'>Product Name : $iname</div>";
echo "<img class = 'item_img' src = '$iimg' alt='image'>";
echo "<div class = 'item_row'><b><h3>Reserve Price : $reserve_price </h3></b></div>";
echo "<div class = 'item_row'><b><h3>Current Bid : ksh.$icurrentp </h3></b></div>";
echo "<div class = 'item_row'><h3> Number of Bids: $bid_num<h3></div>";
echo "<div class = 'item_row'> Payment Method : $payment_method</div>";
echo "<br>";
echo "<div class = 'item_row'> Seller Username : $product_seller</div>";
echo "<br>";
echo "<div class = 'item_row'> Bid endtime : $end</div>";
echo "<br>";
echo "<form action = 'bid.php' method='POST'>";
echo "<input type = 'hidden' name='item_id' value = '$iid' >";
echo "<input type = 'hidden' name = 'username' value = '$username'>";
echo "<select name = 'bid'>";
for($i=0; $i<1000; $i++)
{
$j = $i*10;
echo "<option value = '$j'>ksh.$j</option>";
}
echo "</select>";
echo "<input type = 'submit' value = 'Bid'>";
echo "</form>";
echo "<div class = 'item_row'><a class = 'link' href='$item_details'><button>Product Details </button></a></div>";
echo "</div>";
}/* display all the items on screen*/
$conn->close();
}/* prevent direct access by the user*/
?>
</body>
</html>