php - While loop is not displaying all values -
i having weird problem. there 7 admins: darth, jane, luke, najin, root, sam , sydney.
code:
<table> <tr> <th style="text-align: left; width: 200px;">username</th> <th colspan="2" style="text-align: left;">action</th> </tr> <?php $sql = "select * admins order admin_username asc"; $result = mysqli_query($connection, $sql); $admin = mysqli_fetch_assoc($result); while($admin = mysqli_fetch_assoc($result)) { ?> <tr> <td><?php echo ($admin["admin_username"]); ?></td> <td><a href="edit_admin.php?id=<?php echo urlencode($admin["id"]); ?>">edit</a></td> <td><a href="delete_admin.php?id=<?php echo urlencode($admin["id"]); ?>" onclick="return confirm('are sure want delete admin?');">delete</a></td> </tr> <?php } ?> </table>
if utilize asc
order, first admin, darth not displayed in loop , if utilize desc
order, lastly admin, sydney doesn't show up. problem here?
get rid of first $admin =
line.
your loop fetch of them; don't need fetch first 1 separately (and if fact doing skipping it, because loop fetches sec before first 1 written out).
php while-loop
No comments:
Post a Comment