I have a main PHP page inside of which I have links to more than 50 other pages. In each second page I have some devices from 7 to 15 (nb is not the problem), for every device I have a script that reads from a database the state of each device (online, offline or dead) and for each state the div
background color changes. Now I want the div
background color in the main page to change if any of the devices in the second page has a change of state so I can go into the page and see which device changes and fix the problem.
This is the second page
<div class = "masa-1" id = "id1">
<div <?php $nm = 'em-644'; ?> <?php include 'statusBDE.php'; ?> class = "miniOlm-1" id = "miniOlm-1" <?php echo $color5; ?>; >EM-644</div>
<div <?php include 'statusBDE.php'; $nm = 'em-645'; ?> class = "miniOlm-2" id = "miniOlm-2" <?php echo $color5; ?>; >EM-645</div>
<div <?php include 'statusBDE.php'; $nm = 'em-646'; ?> class = "miniOlm-3" id = "miniOlm-3" <?php echo $color5; ?>; >EM-646</div>
</div>
<div class = "masa-2" id = "id2">
<div <?php include 'statusBDE.php'; $nm = 'em-647'; ?> class = "miniOlm-4" id = "miniOlm-4" <?php echo $color5; ?>; >EM-647</div>
<div <?php include 'statusBDE.php'; $nm = 'em-648'; ?> class = "miniOlm-5" id = "miniOlm-5" <?php echo $color5; ?>; >EM-648</div>
</div>
<div class = "masa-3" id = "id3">
<div <?php include 'statusBDE.php'; $nm = 'em-649'; ?> class = "miniOlm-6" id = "miniOlm-6" <?php echo $color5; ?>; >EM-649</div>
<div <?php include 'statusBDE.php'; $nm = 'em-650'; ?> class = "miniOlm-7" id = "miniOlm-7" <?php echo $color5; ?>; >EM-650</div>
<div <?php include 'statusBDE.php'; $nm = 'em-651'; ?> class = "miniOlm-8" id = "miniOlm-8" <?php echo $color5; ?>; >EM-651</div>
</div>
And the script for it
<?php
include 'connStr.php';
global $nm;
$status = pg_query($db, "SELECT * FROM hosts");
if (!$status) {
echo "Error
";
exit;
}
while ($row = pg_fetch_row($status)) {
if ($row[0] == $nm) {
if ($row[4] == 1 && $row[6] == 1 | $row[6] == 0) {
//$color5 = "#0961ef"; //albastru
$color5 = 'style="background: #0961ef;"';
$sts = '0';
}
elseif ($row[4] == 0 & $row[6] == 1) {
//$color5 = "#f40c0c"; //rosu
$color5 = 'style="background: #f40c0c;"';
$sts = '1';
}
elseif ($row[4] == 0 & $row[6] == 0) {
//$color5 = "#f4f40c"; //galben
$color5 = 'style="background: #f4f40c;"';
$sts = '2';
}
else{
//$color5 ="#f40c0c"; //rosu
$color5 = 'style="background: #f40c0c;"';
$sts = '3';
}
}
}
Now this is loading when I open the page from the main page with onclick
event, everything works just fine, I need the status from this script to change in the same time the div
from the main page. Is the a way to do that? I'm open to any suggestions, thanks.