-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprix.php
More file actions
103 lines (95 loc) · 2.63 KB
/
prix.php
File metadata and controls
103 lines (95 loc) · 2.63 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
<?php include('templates/header.php'); ?>
<h3 align="center"> Prix des ingrédients (au kg) : </h3>
<table class="table table-striped table-hover">
<thead class="thead-light">
<tr>
<th scope="col">Ingredient</th>
<th scope="col">Leader Price</th>
<th scope="col">Rungis</th>
</tr>
</thead>
<tbody>
<?php
// Include config file
require_once "config.php";
$sql = "SELECT nom_ingredient, prix_leader, prix_rungis FROM ingredient";
$result = $conn-> query($sql);
if ($result->num_rows > 0) {
// Affiche les données pour chaque ligne
while($row = $result->fetch_assoc()) {
$prixleader[] = $row['prix_leader'];
$prixrungis[] = $row['prix_rungis'];
echo "<tr><td>" . $row["nom_ingredient"]. "</td><td>" . $row["prix_leader"] . "</td><td>"
. $row["prix_rungis"]. "</td></tr>";
}
echo "</table>";
} else { echo "0 resultats"; }
$conn->close();
?>
</tbody>
</table>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/export-data.js"></script>
<script src="https://code.highcharts.com/modules/accessibility.js"></script>
<figure class="highcharts-figure">
<div id="container"></div>
</figure>
<!-- Diagramme en barres -->
<script>
Highcharts.chart('container', {
chart: {
type: 'column'
},
title: {
text: 'Comparaison des prix'
},
subtitle: {
text: 'Source: www.leaderdrive.fr rungischezvous.com'
},
xAxis: {
categories: [
'Carotte',
'Courgette',
'Ail',
'Echalote',
'Poireau',
'Aubergine',
'Citron jaune',
'Pomme de terre',
'Tomate grappe'
],
crosshair: true
},
yAxis: {
min: 0,
title: {
text: 'Prix (€)'
}
},
tooltip: {
headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
'<td style="padding:0"><b>{point.y:.1f} €</b></td></tr>',
footerFormat: '</table>',
shared: true,
useHTML: true
},
plotOptions: {
column: {
pointPadding: 0.2,
borderWidth: 0
}
},
series: [{
name: 'LeaderPrice',
data: [<?php echo join($prixleader, ',') ?>], color : 'green'
}, {
name: 'Rungis',
data: [<?php echo join($prixrungis, ',') ?>], color : 'orange'
},
]
});
</script>
</body>
</html>