-
Notifications
You must be signed in to change notification settings - Fork 0
/
itemReport.php
97 lines (93 loc) · 2.57 KB
/
itemReport.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
<?php
ob_start();
require_once (__DIR__.'/scripts/config.php');
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="site.css">
<style>
table, th, td {
border: 2px solid black;
border-collapse: collapse;
}
th, td {
padding: 5px;
text-align: left;
}
</style>
</head>
<body>
<div id = "title"><h1>Item Report</h1></div>
<div id = "selector" type = "submit"><form><select name = "selector">
<option value = "descA">Description (ascending)</option>
<option value = "descD">Description (descending)</option>
<option value = "priceA">Price (ascending)</option>
<option value = "priceD">Price (descending)</option>
<?php
$sql="Select itemTypeID, itemTypeName from itemType;";
$querystmt=$DB_con->prepare($sql);
$querystmt->execute();
try{
while($row=$querystmt->fetchObject()){
echo "<option value = {$row->itemTypeID}>{$row->itemTypeName}</option>";
}
}
catch(PDOException $ex)
{
$user->redirect('error.php',$ex->getMessage());
}
?>
</select>
<button type='submit' name='submit' value='selector'>Print Report</button>
</form></div>
<div id = "allItems">
<table>
<tr>
<th>Item Name</th>
<th>Item Type</th>
<th>Item Price</th>
</tr>
<?php
/*Output Result Page */
function selectReport($data){
$returnString = "";
if($data == "descA")
$returnString = " ORDER BY item.itemDescription ASC;";
else if($data == "descD")
$returnString = " ORDER BY item.ItemDescription DESC";
else if($data == "priceA")
$returnString = " ORDER BY item.ItemPrice ASC";
else if($data == "priceD")
$returnString = " ORDER BY item.ItemPrice DESC";
else
$returnString = " AND item.itemTypeID = '$data' ORDER BY item.ItemDescription ASC";
return $returnString;
}
$sql="Select * from item, itemType where item.itemTypeID = itemType.itemTypeID";
if(isset($_GET['submit']))
$selectedRep = $_GET['selector'];
else
$selectedRep = 0;
$sql = $sql.selectReport($selectedRep);
$querystmt=$DB_con->prepare($sql);
$querystmt->execute();
try{
while($row=$querystmt->fetchObject())
{
echo "<tr>";
echo "<td>{$row->itemDescription}</td>";
echo "<td>{$row->itemTypeName}</td>";
echo "<td>{$row->itemPrice}</td>";
echo "</tr>";
}
}
catch(PDOException $ex)
{
$user->redirect('error.php',$ex->getMessage());
}
?>
</table>
</div>
<?php $page_Content=ob_get_contents(); ob_end_clean(); $pagetitle="Item Report" ; include( "master.php"); ?>
</body>
</html>