-
Notifications
You must be signed in to change notification settings - Fork 0
/
read_one.php
65 lines (53 loc) · 1.65 KB
/
read_one.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
<?php
// get ID of the product to be read
$id = isset($_GET['id']) ? $_GET['id'] : die('ERROR: missing ID.');
// include database and object files
include_once 'config/database.php';
include_once 'objects/product.php';
include_once 'objects/category.php';
// get database connection
$database = new Database();
$db = $database->getConnection();
// prepare objects
$product = new Product($db);
$category = new Category($db);
// set ID property of product to be read
$product->id = $id;
// read the details of product to be read
$product->readOne();
// set page headers
$page_title = "Read One Product";
include_once "layout_header.php";
// read products button
echo "<div class='right-button-margin'>";
echo "<a href='index.php' class='btn btn-primary pull-right'>";
echo "<span class='glyphicon glyphicon-list'></span> Read Products";
echo "</a>";
echo "</div>";
// HTML table for displaying a product details
echo "<table class='table table-hover table-responsive table-bordered'>";
echo "<tr>";
echo "<td>Name</td>";
echo "<td>{$product->name}</td>";
echo "</tr>";
echo "<tr>";
echo "<td>Price</td>";
echo "<td>${$product->price}</td>";
echo "</tr>";
echo "<tr>";
echo "<td>Description</td>";
echo "<td>{$product->description}</td>";
echo "</tr>";
echo "<tr>";
echo "<td>Category</td>";
echo "<td>";
// display category name
$category->id=$product->category_id;
$category->readName();
echo $category->name;
echo "</td>";
echo "</tr>";
echo "</table>";
// set footer
include_once "layout_footer.php";
?>