-
Notifications
You must be signed in to change notification settings - Fork 0
/
product.php
executable file
·72 lines (70 loc) · 2.58 KB
/
product.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
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
?>
<?php
if (isset($_GET['id'])) {
// Connect to the MySQL database
include "storescripts/connect_to_mysql.php";
$id = preg_replace('#[^0-9]#i', '', $_GET['id']);
// Use this var to check to see if this ID exists, if yes then get the product
// details, if no then exit this script and give message why
$sql = mysqli_query($conn, "SELECT * FROM `products` WHERE id='$id' LIMIT 1");
$productCount = mysqli_num_rows($sql); // count the output amount
if ($productCount > 0) {
// get all the product details
while($row = mysqli_fetch_array($sql)){
$product_name = $row["product_name"];
$price = $row["price"];
$details = $row["details"];
$category = $row["category"];
$subcategory = $row["subcategory"];
$date_added = strftime("%b %d, %Y", strtotime($row["date_added"]));
}
} else {
echo "That item does not exist.";
exit();
}
} else {
echo "Data to render this page is missing.";
exit();
}
mysqli_close($conn);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http:https://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $product_name; ?></title>
<link rel="stylesheet" href="style/style.css" type="text/css" media="screen" />
</head>
<body>
<div align="center" id="mainWrapper">
<div valign="right" style="height: 300px; width: 1280px; color: #ffffff;
background-image: url(style/bg1.jpg);></div>
<?php include_once("template_header.php");?>
<div id="pageContent">
<table width="100%" border="0" cellspacing="0" cellpadding="15">
<tr>
<td width="19%" valign="top"><img src="inventory_images/<?php echo $id; ?>.jpg" width="142" height="188" alt="<?php echo $product_name; ?>" /><br />
<a href="inventory_images/<?php echo $id; ?>.jpg">View Full Size Image</a></td>
<td width="81%" valign="top"><h3><?php echo $product_name; ?></h3>
<p><?php echo "₹".$price; ?><br />
<br />
<?php echo "$subcategory $category"; ?> <br />
<br />
<?php echo $details; ?>
<br />
</p>
<form id="form1" name="form1" method="post" action="cart.php">
<input type="hidden" name="pid" id="pid" value="<?php echo $id; ?>" />
<input type="submit" name="button" id="button" value="Add to Shopping Cart" />
</form>
</td>
</tr>
</table>
</div>
<?php include_once("template_footer.php");?>
</div>
</body>
</html>