-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpricelist.php
82 lines (75 loc) · 1.69 KB
/
pricelist.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
74
75
76
77
78
79
80
81
82
<html>
<head>
<title>Food stop</title>
<style>
table {
margin-left: auto;
margin-right: auto;
border: 1px solid #777777;
border-collapse: collapse;
}
th {
background-color: #777777;
}
tr.p1 {
background-color: #dddddd;
}
#container {
width: 100%;
}
</style>
</head>
<body>
<h1>Food stop</h1>
<?php
include('db.php');
$pg1 = '<div id="container">';
try {
$pg1 = '<table>';
$pg1 .= '<tr>';
$pg1 .= '<th>Type</th><th>Description</th><th>Prix unitaire</th><th>En stock</th>';
$pg1 .= '</tr>';
$db = new PDO($db_pdostr, $db_user, $db_pass);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $db->prepare("SELECT foodstop_categories.name AS catname, foodstop_items.* FROM foodstop_items,foodstop_categories WHERE foodstop_items.category = foodstop_categories.id ORDER BY foodstop_items.category ASC, foodstop_items.desc ASC");
$stmt->execute(array());
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
$i = 0;
foreach ($rows as $row)
{
$i++;
if ($i % 2 == 0)
{
$pg1 .= '<tr>';
}
else
{
$pg1 .= '<tr class=\'p1\'>';
}
if ($row['price'] > 0)
{
$pg1 .= '<td>'.$row['catname'].'</td><td>'.$row['desc'].'</td><td>$'.$row['price'].'</td><td>'.$row['stock'].'</td>';
/*
$percentage = 100*($row['retail_price']-$row['price'])/$row['price'];
if ($percentage != 0)
{
$pg1 .= '<td>$'.$row['retail_price'].' ('.round(100*($row['retail_price']-$row['price'])/$row['price'],0).'%)</td>';
}
else
{
$pg1 .= '<td></td>';
}
}*/
}
$pg1 .= '</tr>';
}
$pg1 = $pg1."\n".'</table>';
}
catch (PDOException $ex)
{
$pg1 = 'Database error: '.$ex->getFile().':'.$ex->getLine().' -> '.$ex->getMessage();
}
$pg1 .= '</div>';
echo $pg1;
?>
</body>