ScudBud ScudBud - 5 months ago 9x
PHP Question

only showing certain level users

I am showing a list of users information. The users are set at different levels (1-5). I only want it to display information for users that are level 1. Here is basically the code.

<?php while ($rrows = mysql_fetch_array($rs_results)) {?>
<td><input name="u[]" type="checkbox" value="<?php echo $rrows['id']; ?>" id="u[]"></td>
<td><?php echo $rrows['date']; ?></td>
<td><?php echo $rrows['user_level']; ?></td>
<td><?php echo $rrows['user_name'];?></td>
<td><?php echo $rrows['user_email']; ?></td>
<td> <span id="approve<?php echo $rrows['id']; ?>">
<?php if(!$rrows['approved']) { echo "Pending"; } else {echo "Active"; }?>
</span> </td>
<td><span id="ban<?php echo $rrows['id']; ?>">
<?php if(!$rrows['banned']) { echo "no"; } else {echo "yes"; }?>
</span> </td></tr>

How would I say to display only information of users who's 'user_level' = '1'?


You could filter in two ways:

  • directly in the query, as indicated by @Fred
  • after fetching the recordset:

while ($rrows = mysql_fetch_array($rs_results)){

      if ($rrows['user_level'] == 1){
         // display as previously