forked from cyklokoalicia/OpenSourceBikeShare
-
Notifications
You must be signed in to change notification settings - Fork 0
/
report.php
99 lines (79 loc) · 2.43 KB
/
report.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="sk" lang="sk">
<head><title>Report</title>
<meta http-equiv="Expire" content="now" />
<meta http-equiv="Pragma" content="no-cache" />
<meta name="description" content="DATANEST na mape"/>
<meta name="copyright" content="Copyright (c) 2011 Michal Maly"/>
<meta name="author" content="Michal Maly"/>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<link href="style.css" type="text/css" rel="stylesheet" />
</head>
<body>
<h2>Report pouzitia</h2>
<?php
error_reporting(-1);
require("config.php");
function report()
{
global $dbserver, $dbuser, $dbpassword, $dbname;
$mysqli = new mysqli($dbserver, $dbuser, $dbpassword, $dbname);
if ($result = $mysqli->query("SELECT bikes.bikeNum,userName,standName,note FROM bikes left join users on
bikes.currentUser=users.userId left join (select * from notes
where deleted is null ) as notes on notes.bikeNum=bikes.BikeNum left
join stands on bikes.currentStand=stands.standId
order by standName,bikeNum LIMIT 100"))
{
while($row=$result->fetch_assoc())
{
echo $row["bikeNum"]," ",$row["userName"],$row["standName"]," ",$row["note"],"<br/>";
}
}
else
{
echo "problem s sql dotazom";
error("rented bikes not fetched");
}
}
function reportStands()
{
global $dbServer, $dbUser, $dbPassword, $dbName;
$mysqli = new mysqli($dbServer, $dbUser, $dbPassword, $dbName);
if ($result = $mysqli->query("
SELECT stands.standName,note FROM stands join (select * from notes
where deleted is null ) as notes on notes.standId=stands.standId
order by standName,note LIMIT 100 "))
{
$data = $result->fetch_all(MYSQLI_ASSOC);
}
else
{
echo "problem s sql dotazom";
error("users bikes not fetched");
}
echo '<table style="width:50%">';
# echo '<caption>last usage</caption>';
echo "<tr>";
$cols = array("standName","note");
foreach($cols as $col)
{
echo "<th>$col</th>";
}
echo "</tr>";
for($i=0; $i<count($data);$i++)
{
echo "<tr>";
foreach($cols as $col)
{
echo "<td>";
echo $data[$i][$col];
echo "</td>";
}
echo "</tr>";
}
echo "</table>";
}
report();
reportStands();
?>
</body></html>