In PHP I need to change <li> font color when IP adress:
Is reachable = Lime color
Not reachable = Red color
Below is code I have already tried, and it not working.
Main query: $stmt = $pdo -> query('SELECT ip FROM cameras');
echo '<ul>';
while($row = $stmt -> fetch()) {
echo '<li style=\'color: $color;\'>'.$row['ip'].'</li>';
}
$stmt -> closeCursor();
echo '</ul>';
$check = $row['ip'];
$ping = exec("ping -n 1 $check", $out, $result);
$yes_ping = strpos($ping, 'ms');
if($yes_ping != FALSE) {
$color = "lime";
} else {
$color = "red";
}
Aucun commentaire:
Enregistrer un commentaire