Repository navigation
Expand file tree
/
Copy pathindex.php
More file actions
74 lines (61 loc) · 2.18 KB
/
Copy pathindex.php
File metadata and controls
74 lines (61 loc) · 2.18 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
<?php
require 'config/conn.php';
require 'include/header.php';
if (isset($_GET['q'])) {
$SQL = $conn->prepare("Select p.Id as Id, p.Price, p.Qty, p.Description, Promotion.Discount, p.Name from Product p
LEFT OUTER JOIN Promotion on
p.Id = Promotion.ProductID where p.Name like ? OR p.Description like ?");
$parameter = '%' . $_GET['q'] . '%';
$SQL->execute(array($parameter,$parameter));
}
else {
$SQL = $conn->prepare("Select p.Id as Id, p.Price, p.Qty, p.Description, Promotion.Discount, p.Name from Product p
LEFT OUTER JOIN Promotion on
p.Id = Promotion.ProductID");
$SQL->execute();
}
?>
<div class="form-group col-md-4">
<input type="search" id="value" class="form-control"/>
<input type="button" id="search" class="btn btn-default" value="Search" />
</div>
<div style="clear: both;"></div>
<br/>
<br/>
<?php
while ($info = $SQL->fetch()) {
?>
<a href="productdetails.php?Id=<?=$info["Id"]?>">
<div class="col-sm-4 col-lg-4 col-md-4">
<div class="thumbnail">
<img src="http://placehold.it/320x150" alt="">
<div class="caption">
<h4 class="pull-right">
<?=$info["Discount"]==NULL ?
'$' .$info["Price"] :
'<strong>$' .
$info["Price"]*(1 - $info["Discount"]) .
'</strong> <strike>' . $info["Price"] .'</strike>'
?>
</h4>
<h4><a href="#"><?=$info["Name"]?></a>
</h4>
<p><?=$info["Description"]?></p>
</div>
<div class="ratings">
<p class="pull-right">15 reviews</p>
<p>
<span>Quantity: <?=$info["Qty"]?></span>
</p>
</div>
</div>
</div>
</a>
<?
}
?>
<br/>
<br/>
<?php
require 'include/footer.php';
?>