-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproduct.php
More file actions
105 lines (92 loc) · 2.41 KB
/
product.php
File metadata and controls
105 lines (92 loc) · 2.41 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
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
98
99
100
101
102
103
104
105
<?php
class Product
{
private int $id;
private string $name;
private string $category;
private string $description;
private int $price;
private string $rating;
private string $imageName;
private int $quantity;
public function getId()
{
return $this->id;
}
public function getName()
{
return $this->name;
}
public function getCategory()
{
return $this->category;
}
public function getDescription()
{
return $this->description;
}
public function getPrice()
{
return $this->price;
}
public function getRating()
{
return $this->price;
}
public function getImageName()
{
return $this->imageName;
}
public function getQuantity()
{
return $this->quantity;
}
//to display each product in row in table
public function displayInTable()
{
$deleteLink = "delete.php?id={$this->id}";
$row = <<<REC
<tr>
<td><figure ><img src="{$this->getImageName()}" alt="{$this->getName()}" style="max-width: 90px;" ></figure> </td>
<td><a href="view.php?id={$this->getId()}">{$this->getId()}</a></td>
<td>{$this->getName()}</td>
<td>{$this->getCategory()}</td>
<td>{$this->getPrice()}</td>
<td>{$this->getQuantity()}</td>
<td>
<div>
<button type="button"><a href="edit.php?id={$this->getId()}"><img src='./images/edit.png' alt='edit'></a></button>
<button type="button"><a href="delete.php?id={$this->getId()}"><img src='./images/delete.png' alt='delete'></a></button>
</div>
</td>
</tr>
REC;
return $row;
}
// to display each product in page
function displayProdcutPage()
{
$main = <<<REC
<main>
<article>
<figure>
<img src="$this->imageName" alt="$this->name">
</figure>
</article>
<section>
<h1>Product ID: $this->id, $this->name</h1>
<ul>
<li>Price: $this->price</li>
<li>Category: $this->category</li>
<li>Rating: $this->rating/5</li>
</ul>
</section>
<section>
<h1>Description:</h1>
<p>$this->description</p>
</section>
</main>
REC;
return $main;
}
}