From 13bab0694648f419b76f728f0a5f3af0eea6659e Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Wed, 20 Jul 2022 14:42:45 +0200 Subject: index.php: show highest 0 and 1 --- html/index.php | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/html/index.php b/html/index.php index 2c15cde..8fb46da 100644 --- a/html/index.php +++ b/html/index.php @@ -8,11 +8,11 @@ $result = $db -> query( ' JOIN "values" ON machines.id = "values".machine_id' . ' JOIN states ON "values".state_id = states.id' . ' WHERE "values".value IS NOT NULL' . - ' GROUP BY machines.id' + ' GROUP BY machines.id, "values".value' ); $stm = $db -> prepare( - 'SELECT machines.name as machine, states.name as state, "values".value' . + 'SELECT machines.name as machine, machines.last_update, states.name as state, "values".value' . ' FROM machines' . ' JOIN "values" ON "values".machine_id = machines.id' . ' JOIN states ON "values".state_id = states.id' . @@ -25,7 +25,9 @@ while ($row = $result -> fetchArray()) { $stm -> bindValue('machine', $row['machine']); $stm -> bindValue('state', $row['min_state']); $stmres = $stm -> execute(); - $values[$row['machine']] = $stmres -> fetchArray(); + $stmres = $stmres -> fetchArray(); + $values[$row['machine']][$stmres['value']] = $stmres; + $values[$row['machine']]['any'] = $stmres; } $stm -> close(); @@ -38,20 +40,29 @@ $stm -> close(); ' . $text . ''; +function colorize($color, $text) { + return '' . $text . ''; } foreach ($values as $value) { + + if (array_key_exists('0', $value)) + $color = '#800000'; + else + $color = '#008000'; + ?> - - - + + +