-
Notifications
You must be signed in to change notification settings - Fork 1
/
findProduct.php
88 lines (64 loc) · 1.48 KB
/
findProduct.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
<?
ob_start();
session_start();
/* the employee table and its types
*/
require("database.php"); //contains the method to access the db
if ( !isset($_SESSION['eid']) ){ //checks if you are logged in
echo "Error, you are not allowed to see this page. Log in as Manager";
}
else {//if ( $_SESSION['manager'] == 1 ) { //checks if you are the manager
//$query = "select * from inventory order by pid asc";
//$result = mysql_query($query);
//$row = mysql_fetch_array($result);
//html code
echo "
<html>
<head>
<title>Find a product</title>
</head>
<body>";
//the form
echo "<form name = 'find' action='findProduct.php' type='get'>
Type in the PID or Name of the product:
<input type='text' name=q>
<input type='submit'> <br/>";
if ( isset($_GET['q']))
{
$q = $_GET['q'];
$query = "select * from inventory where name='$q' or pid='$q'";
//echo "$query";
echo "Query is <i><br/>" . $query . "</i><br/>";
$result = mysql_query($query);
//the column names
echo "<table border=1>
<tr>
<td>PID#</td>
<td>Name </td>
<td>Price </td>
<td>Description </td>
<td>Purchase Date </td>
</tr>";
//the tuples
while($row = mysql_fetch_array($result)) {
$pid = $row['pid'];
$name = $row['name'];
$price = $row['price'];
$description = $row['description'];
$purchasedate = $row['purchasedDate'];
echo "
<tr>
<td> $pid </td>
<td> $name </td>
<td>$ $price </td>
<td> $description </td>
<td> $purchasedate </td>
</tr>";
}
//finish the columns
echo "</table>";
}
//end html
echo "</body></html>";
}
?>