From 0db78b654f3add280e5532962eef21c8601c771b Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Thu, 28 Jul 2022 17:40:11 +0200 Subject: value=0 should be minimal state, value=1 should stay maximal state --- html/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/html/index.php b/html/index.php index 8fb46da..df6d4dc 100644 --- a/html/index.php +++ b/html/index.php @@ -3,7 +3,7 @@ include "db.php"; $result = $db -> query( - 'SELECT machines.id as machine, MIN(states.id) as min_state' . + 'SELECT machines.id as machine, IIF("values".value = 1, MIN(states.id), MAX(states.id)) as minax_state' . ' FROM machines' . ' JOIN "values" ON machines.id = "values".machine_id' . ' JOIN states ON "values".state_id = states.id' . @@ -23,7 +23,7 @@ $values = array(); while ($row = $result -> fetchArray()) { $stm -> bindValue('machine', $row['machine']); - $stm -> bindValue('state', $row['min_state']); + $stm -> bindValue('state', $row['minax_state']); $stmres = $stm -> execute(); $stmres = $stmres -> fetchArray(); $values[$row['machine']][$stmres['value']] = $stmres; -- cgit v1.2.3-54-g00ecf