-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshirt-detail.php
73 lines (71 loc) · 2.01 KB
/
shirt-detail.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
<?php include("database.php"); ?>
<?php
if(isset($_GET["id"]))
{
$product_id=intval($_GET["id"])+101;
try{
$result=$db->prepare("SELECT * from product where id=?");
$result->bindParam(1,$product_id);
$result->execute();}
catch(exception $e)
{
echo "OOPS! data cannot be fetched from Database";
}
/*"select size from sizes where size_id in (select size_id from product_sizes where product_id=? )"*/
$product=$result->fetch(PDO::FETCH_ASSOC);
$product["sizes"]=array();
if(isset($product)){
try{
$result_nw=$db->prepare("select size from product_sizes ps inner join sizes s on ps.size_id=s.size_id where product_id=?");
$result_nw->bindParam(1,$product_id);
$result_nw->execute();
}
catch(exception $e)
{
echo "OOPS! data cannot be fetched from Database";
}
$product["sizes"]=$result_nw->fetch(PDO::FETCH_ASSOC);
//print_r($product);
var_dump($result_nw->fetch(PDO::FETCH_ASSOC));
while($row=$result_nw->fetch(PDO::FETCH_ASSOC));
{
echo "Hie";
$product["sizes"][]=$row["size"];
}}
}
if(empty($product))
{
header("location:shirts.php");
exit();
}
$header=$product["name"];
include("header.php");
?>
<html>
<div class="format"><br><br>
<a href="shirts.php">
<b>All Shirts</b>
</a> <b> > <?php echo $product["name"];?> </b><br><br>
<div class="row">
<div class="col-md-6">
<img src="<?php echo $product["img"]; ?>" width="300">
</div>
<div class="col-md-6">
<div class="price">$<?php echo $product["price"];?> <h3><?php echo $product["name"];?></h3>
<h6>* All Shirts are Designed by Professional Designers</h6></div>
<form action="#">
<br><br>
<select>
<?php foreach($product["sizes"] as $size) {?>
<option value="<?php echo $size ?>"><?php echo $size ?></option>
<?php } ?>
</select><br><br>
<button class="btn b">Add TO Cart</button>
</form>
</div>
</div>
</div>
</html>
<?php
include("footer.php");
?>