From 5867b16444b8808f30d38d24f7fec2aba5c663c1 Mon Sep 17 00:00:00 2001 From: Robert Anderson <randerson@lbsd.net> Date: Wed, 25 Mar 2009 09:38:54 +0000 Subject: [PATCH] added check for empty list --- webui/user-attributes.php | 48 ++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/webui/user-attributes.php b/webui/user-attributes.php index 6ff1f9af..7d947be3 100644 --- a/webui/user-attributes.php +++ b/webui/user-attributes.php @@ -75,37 +75,49 @@ printHeader(array( </tr> <?php $_SESSION['attr_user_id'] = $_POST['user_id']; - if (isset($_SESSION['attr_user_id'])) { + if (isset($_POST['user_id'])) { $temp = $_SESSION['attr_user_id']; $sql = "SELECT ID, Name, Operator, Value, Disabled FROM ${DB_TABLE_PREFIX}user_attributes WHERE UserID = $temp ORDER BY ID"; $res = $db->query($sql); - if ($res) { - while ($row = $res->fetchObject()) { + $rownums = 0; + while ($row = $res->fetchObject()) { + if ($row->id != NULL) { + $rownums = $rownums + 1; + } else { + $rownums = $rownums - 1; + } ?> - <tr class="resultsitem"> - <td><input type="radio" name="attr_id" value="<?php echo $row->id ?>"/><?php echo $row->id ?></td> - <td><?php echo $row->name ?></td> - <td><?php echo $row->operator ?></td> - <td><?php echo $row->value ?></td> - <td class="textcenter"><?php echo $row->disabled ? 'yes' : 'no' ?></td> - </tr> + <tr class="resultsitem"> + <td><input type="radio" name="attr_id" value="<?php echo $row->id ?>"/><?php echo $row->id ?></td> + <td><?php echo $row->name ?></td> + <td><?php echo $row->operator ?></td> + <td><?php echo $row->value ?></td> + <td class="textcenter"><?php echo $row->disabled ? 'yes' : 'no' ?></td> + </tr> <?php - } - $res->closeCursor(); } + $res->closeCursor(); + if ($rownums <= 0) { ?> - </table> -</form> + <p /> + <tr> + <td colspan="5" class="textcenter">Group attribute list is empty</td> + </tr> <?php -} else { + } + unset($rownums); + } else { ?> - <div class="warning">Invocation error, no user ID selected</div> + <tr class="resultitem"> + <td colspan="5" class="textcenter">No User ID selected</td> + </tr> <?php -} - + } ?> + </table> +</form> <?php printFooter(); -- GitLab