-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin_load_vehicles.php
45 lines (39 loc) · 1.19 KB
/
admin_load_vehicles.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
<?php
require "include/template2.inc.php";
require "include/dbms.inc.php";
global $conn;
$body = new Template("skins/admin/dtml/row_veicolo.html");
$targa = $_POST['targa'];
if($targa == "no") {
$query = "SELECT id, marca, modello, cambio, km_percorsi, targa
FROM veicolo ORDER BY targa";
$vehicles = $conn->query($query);
if ($vehicles) {
if ($vehicles->num_rows > 0) {
while ($row = $vehicles->fetch_assoc()) {
foreach ($row as $key => $value) {
$body->setContent($key, $value);
}
}
}
}
echo $body->get();
}
else {
$query = "SELECT id, marca, modello, cambio, km_percorsi, targa
FROM veicolo WHERE targa='$targa'";
$vehicles = $conn->query($query);
if ($vehicles) {
if ($vehicles->num_rows == 1) {
$row = $vehicles->fetch_assoc();
foreach ($row as $key => $value) {
$body->setContent($key, $value);
}
echo $body->get();
} else {
$error = new Template("skins/admin/dtml/veicolo_not_found.html");
echo $error->get();
}
}
}
?>