Esempio n. 1
0
<?php

require_once "./MySQLiWrapper.php";
require_once "./CalcHumidity.php";
$calc = new CalcHumidity();
// Connect to the database
$db_wrapper = new MySQLiWrapper("localhost", "root", "", "unwdmi");
// Select rows from stations
$result = $db_wrapper->query("SELECT stn, name, country, latitude, longitude \n\t\t\t\t\t\t\t      FROM stations \n\t\t\t\t\t\t\t      WHERE stn={$_GET['stn']}");
$row = mysql_fetch_row($result);
echo "\n\t<tr>\n\t\t<td>\n\t\t\t<table id='station-info'>\n\t\t\t\t<tr>\n\t\t\t\t\t<th>STN</th>\n\t\t\t\t\t<th>Name</th>\n\t\t\t\t\t<th>Country</th>\n\t\t\t\t\t<th>Latitude</th>\n\t\t\t\t\t<th>Longitude</th>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td>{$row[0]}</td>\n\t\t\t\t\t<td>{$row[1]}</td>\n\t\t\t\t\t<td>{$row[2]}</td>\n\t\t\t\t\t<td>{$row[3]}</td>\n\t\t\t\t\t<td>{$row[4]}</td>\n\t\t\t\t</tr>\n\t\t\t</table>\n\t\t</td>\n\t</tr>";
$result = $db_wrapper->query("SELECT datetime, TEMP, DEWP\n\t\t\t\t\t\t\t      FROM measurements\n\t\t\t\t\t\t\t      WHERE STN={$_GET['stn']}\n\t\t\t\t\t\t\t      ORDER BY datetime DESC\n\t\t\t\t\t\t\t      LIMIT 30");
echo "\n\t<tr>\n\t\t<td>\n\t\t\t<table id='measurements'>\n\t\t\t\t<tr>\n\t\t\t\t\t<th>Datetime</th>\n\t\t\t\t\t<th>Tempature℃</th>\n\t\t\t\t\t<th>Humidity%</th>\n\t\t\t\t</tr>";
while ($row = mysql_fetch_assoc($result)) {
    echo "<tr>";
    echo "<td>{$row['datetime']}</td>";
    echo "<td>{$row['TEMP']}</td>";
    echo "<td>" . $calc->calcSingle($row['TEMP'], $row['DEWP']) . "</td>";
    echo "</tr>";
}
echo "\n\t\t\t</table>\n\t\t</td>\n\t</tr>";
Esempio n. 2
0
<?php

include "../class/MySQLiWrapper.php";
// Start XML file, create parent node
$dom = new DOMDocument("1.0");
$node = $dom->createElement("markers");
$parnode = $dom->appendChild($node);
// Connect to the database
$db_wrapper = new MySQLiWrapper("localhost", "root", "", "unwdmi");
// Select rows from stations
$result = $db_wrapper->query("SELECT stn, latitude, longitude FROM stations");
header("Content-type: text/xml");
// Iterate through the rows, adding XML nodes for each
while ($row = mysqli_fetch_assoc($result)) {
    // ADD TO XML DOCUMENT NODE
    $node = $dom->createElement("marker");
    $newnode = $parnode->appendChild($node);
    $newnode->setAttribute("stn", $row['stn']);
    $newnode->setAttribute("latitude", $row['latitude']);
    $newnode->setAttribute("longitude", $row['longitude']);
}
echo $dom->saveXML();