<?php
// Utility sample for Aspicore GSM Tracker
// Show the tracking data from the MySQL database
//
// You can use this sample to see, what data storesql.php has stored into the database
//
// Usage: Go to the URL of this page with your Internet browser,
// e.g. http://<YourWebServer>/listsql.php
//
// (c) Aspicore Ltd 2005, www.aspicore.com
//
// Tested with PHP 5.0.3, Windows XP, IIS 5.1, MySQL 4.1.10a-nt and with Windows Server 2003, IIS 6.0
// The mysqli extension of PHP requires version 4.1.3 or above of MySQL
//
// NB. If you are using PHP with IIS, set output_buffering = On in php.ini
// In Windows, remember to enable extension=php_mysqli.dll in php.ini
// make
also sure, that php_mysqli.dll is at location php.ini/extension_dir
// and that libmySQL.dll is along the system path
// ------------------------------
// Change History:
// 2005-04-01 jje - SQL script created
header("Expires: 0");
header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
header("Pragma: no-cache");
header("Content-Type: text/html; charset=ISO-8859-1");
header('Content-Disposition: inline; filename="response.html"');
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<style type="text/css">
<!--
td { font-family: verdana,arial,helvetica,sans-serif; font-size: 9pt;
border: 1px solid black;
vertical-align: baseline }
th { font-family: verdana,arial,helvetica,sans-serif; font-size: 7pt; font-weight: bold;
border: 1px solid black;
border-style: solid; border-width: 1px;
vertical-align: baseline }
td.small { font-family: verdana,arial,helvetica,sans-serif; font-size: 6pt }
body { font-family: Courier New,MONOSPACE; font-size: 9pt }
base { font-family: Courier,MONOSPACE; font-size: 10pt }
table { border-collapse: collapse; border: solid thin black }
caption { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold }
-->
</style>
<title>List SQL</title>
</head>
<body>
<?php
// Show time in the response to the HTTP client
$timestamp = gmdate("D, d M Y H:i:s");
echo "<p>\n" ;
echo "Report Date:\n";
echo $timestamp . "\n";
echo "Greenwich Mean Time (GMT)\n";
echo "</p>\n" ;
//------------------------
// Make a SELECT query to the MySQL database
// (Create database 'gsmtrack' first with script GSM_Tracker_MySQL_tab.sql)
//------------------------
// Connecting, selecting database
// ***********************************************************************
// mysqli_connect parameters: host, username, passwd, dbname
$link = mysqli_connect("localhost", "root", "newpwd", "gsmtrack");
// ***********************************************************************
/* check connection */
if (!$link) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
//echo 'Connected successfully';
// Performing SQL query
$query = 'SELECT * FROM GPS ORDER BY GPSMSGID DESC LIMIT 100';
$result = mysqli_query($link, $query);
if (!$result) {
printf("Query failed: %s\n", mysqli_error($link));
exit();
}
echo "<p>\n" ;
echo "The 100 most recent messages from Aspicore GSM Tracker\n";
echo "</p>\n" ;
// Printing results in HTML
echo '<table border="1">' . "\n";
// Table header
echo "\t<tr>\n";
$finfo = mysqli_fetch_fields($result);
for ($i=0; $i < count($finfo); $i++) {
$fieldname = str_replace ("_", " ", $finfo[$i]->name);
echo "\t\t<th>" . $fieldname . "</th>\n";
}
echo "\t</tr>\n";
// Table content
while ($line = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
echo "\t<tr>\n";
foreach ($line as $col_value) {
echo "\t\t<td>$col_value</td>\n";
}
echo "\t</tr>\n";
}
echo "</table>\n";
// Free resultset
mysqli_free_result($result);
/* close connection */
mysqli_close($link);
//------------------------
?>
</body>
</html>