I'm currently working on a status website for where I work. The aim of it is to display which systems and services are running or not, in the form of a tick or cross next to the services name.
I have a database with the names of the services inside, as well as a value of either A or B. A should result in a tick, B should result in a cross.
I've got the code together to retrieve the A or B, and display it in a table next to the corresponding name, but I'd like either the tick or cross to display instead.
The tick is located at 'sources/tick.png', and the cross is located at 'sources/cross.png'.
Could anyone give me some pointers on how I can achieve this? Thanks a lot!
Below is my code (I know its messy but I'm still learning):
<?php
$mysqli = new mysqli("localhost", "root", "password", "status");
if ($mysqli->connect_errno) {
echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}
echo '<img width="1%" src="sources/tick.png">' . "
";
$sql1 = "SELECT wifi from status";
if(!$result1 = $mysqli->query($sql1)){
die('There was an error running the query [' . $db->error . ']');
}
$sql2 = "SELECT internet from status";
if(!$result2 = $mysqli->query($sql2)){
die('There was an error running the query [' . $db->error . ']');
}
?>
<html>
<head>
<title>Network Status</title>
<link rel="stylesheet" href="sources/styles.css">
</head>
<body>
<div id="header" align="center">
<img class="headerImg" src="sources/logo.png"><br />
<font class="headerTxt">The Current Network Status:</font>
</div>
<div id="wrapper" align="center">
<table align="center">
<tr>
<td align="center"><span class="statusItm" id="wifi"><font class="statusTxt">WiFi</font></span></td>
<td align="center"><span id="wifi"><?php while($row = $result1->fetch_assoc()){echo $row['wifi'] . '<br />';} ?></span></td>
</tr>
<tr>
<td align="center"><span class="statusItm" id="internet"><font class="statusTxt">Internet Access</font></span></td>
<td align="center"><span id="internet"><?php while($row = $result2->fetch_assoc()){echo $row['internet'] . '<br />';} ?></span></td>
</tr>
</table>
</div>
</body>
</html>
Jack