<?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>";
</tr> </thead> <tbody> <?php $weather_data = $conn->getStationData($station); while ($row = mysql_fetch_assoc($weather_data)) { /* */ ?> <tr> <td class="col-md-1"><?php echo $row["datetime"]; ?> </td> <td class="col-md-1"><?php echo $calculator->calcSingle($row["temp"], $row["dewp"]) . "%"; ?> </td> </tr> <?php } ?> </tbody> </table>