-
Notifications
You must be signed in to change notification settings - Fork 0
/
testItem1.php
73 lines (61 loc) · 1.83 KB
/
testItem1.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
<!DOCTYPE html>
<html>
<head>
<title>Frontpage</title>
<meta charset="utf-8">
<link rel="shortcut icon" href="favicon.ico">
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="css/main.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<script defer src="https://use.fontawesome.com/releases/v5.0.7/js/all.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="js/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
</head>
<body>
<?php
// Get product details
include('db.php');
$ptid = 1;
$query = $conn->query("SELECT `p`.`productName`, `pt`.* FROM `productType` AS `pt`
JOIN `product` AS `p`
ON `p`.`pid` = `pt`.`pid`
WHERE `ptid` = " . $ptid);
$row = $query->fetch();
$itemType = array(
'kilo' => $row['kilo'],
'box' => $row['box'],
'bunch' => $row['bunch'],
'punnet' => $row['punnet'],
'single' => $row['single']
);
//compare the array to find lowest price as starting point
$minimum = 1000.00;
//echo $min;
foreach( $itemType as $key => $value )
{
echo $value . '<br>';
if ($value > 0 & $value < $minimum)
{
$minimum = $value;
}
}
echo 'By FOREACH ' . $minimum . '<br>';
//echo $currentMin = array_search(min($itemType),$itemType);
/*$minimum = min(array($kilo ,
$box ,
$bunch ,
$punnet ,
$single ));
echo 'By MINARRAY ' . $minimum . '<br>';
*/
$itemCart = array(
'price' => number_format( $minimum, 2, ".", "," ),
'qty' => 1
);
foreach( $itemCart as $key=>$value ){
echo 'CART FOREACH ' . $key . ' = ' . $value . '<br>';;
}
?>
</body>
</html>