diff options
Diffstat (limited to 'html/index.php')
-rw-r--r-- | html/index.php | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/html/index.php b/html/index.php index 38f4f3d..776694b 100644 --- a/html/index.php +++ b/html/index.php @@ -11,14 +11,23 @@ $result = $db -> query( ' GROUP BY machines.id' ); -$result = $db -> query( -// 'SELECT machines.name as machine, GROUP_CONCAT(states.name || \': \' || "values".value, \',\') as state, last_update' . - 'SELECT machines.name as machine, GROUP_CONCAT(states.name || \': \' || IFNULL("values".value, \'NULL\'), \',\') as state, machines.last_update' . +$stm = $db -> prepare( + 'SELECT machines.name as machine, states.name as state, "values".value' . ' FROM machines' . - ' JOIN "values" ON machines.id = "values".machine_id' . + ' JOIN "values" ON "values".machine_id = machines.id' . ' JOIN states ON "values".state_id = states.id' . - ' GROUP BY machines.id' + ' WHERE machines.id = :machine' . + ' AND states.id = :state' ); +$values = array(); + +while ($row = $result -> fetchArray()) { + $stm -> bindValue('machine', $row['machine']); + $stm -> bindValue('state', $row['min_state']); + $stmres = $stm -> execute(); + $values[$row['machine']] = $stmres -> fetchArray(); +} +$stm -> close(); ?> <html><body><table> @@ -29,11 +38,16 @@ $result = $db -> query( </tr> <?php -while ($row = $result -> fetchArray()) { -?> -<tr> - <td><?php echo $row['machine']; ?></td> - <td><?php echo $row['state']; ?></td> +foreach ($values as $value) { +?> <tr> + <td><?php echo $value['machine']; ?></td> + <td><?php + +if ($value['value'] != 1) + echo 'not '; +echo $value['state']; + +?></td> <td><?php echo $row['last_update']; ?></td> </tr> <?php |