-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathitemList.php
More file actions
67 lines (63 loc) · 2 KB
/
itemList.php
File metadata and controls
67 lines (63 loc) · 2 KB
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
<?php
session_start();
include('db.php');
include('header.php');
if(!isset($_SESSION['key']))
{
header("Location: /stuff-sharing/login.php?error=NOT_LOGIN");
}
elseif(isset($_POST['itemid']))
{
header("Location: /stuff-sharing/bid.php?id=".$_POST['itemid']);
}
else
{
$email = pg_escape_string($connection,$_SESSION['key']);
$query = "SELECT firstName, lastName, userpoint FROM users where email='".$email."'";
$result = pg_query($connection,$query) or die('Query failed:'.pg_last_error());
$row = pg_fetch_row($result);
}
$itemresult = pg_query($connection,"SELECT l.itemName,l.itemId,l.itemCategory,l.itemDescription FROM ItemList l, Advertise a WHERE l.itemId = a.itemId ORDER BY itemName ASC");
//get particulars
$particulars = pg_query($connection,"SELECT u.firstname, u.lastname, u.dob, u.email FROM users u WHERE u.email = '".$email."'")
or die ('Query failed: '.pg_last_error());
?>
<body>
<?php
include('navbar.php');
?>
<div class="container">
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">ItemList</h3>
</div>
<div class="panel-body">
<div class="table-responsive">
<table class="table table-striped table-bordered table-list">
<thead>
<tr>
<th>itemName</th> <th>itemId</th> <th>itemCategory</th> <th>itemDescription</th> <th>View details</th>
</tr>
</thead>
<?php
while($row = pg_fetch_array($itemresult, null, PGSQL_ASSOC)){
echo "\t<tbody>\n\t<tr>\n";
foreach ($row as $col_value) {
echo "\t\t<td>$col_value</td>\n";
}
echo "\t\t<td><form action=\"itemList.php\" method=\"post\">";
echo "<input type=\"hidden\" name=\"itemid\" value=\"".$row['itemid']."\"/>";
echo "<button type=\"submit\" class=\"btn btn-success\">View</button></form></td>\n";
echo "\t</tr>\n\t</tbody>\n";
}
?>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</body>