diff options
-rw-r--r-- | html/index.php | 4 |
1 files 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; |