How to remove an "item" from the last record?

  • I need the last record not to show <div class="staffClearFix"></div>

        $userdata = mysql_query("SELECT * FROM users WHERE rank = '9' AND status = 'Ativo' ORDER BY id");
        while($row = mysql_fetch_assoc($userdata)){
        <?php echo $row['username']; ?>
        <div class="staffClearFix"></div>   
    <?php } ?>

  • Reverse the order and add a logic to delete from the first record that will become easier:

    $first = true;
    while($row = mysql_fetch_assoc($userdata)) {
       if (!$first) 
           echo '<div class="staffClearFix"></div>';

    echo $row['username'];

    $first = false;

    Other details do not use functions they are obsolete since version 5.5 and removed in PHP 7. Use or

Suggested Topics