Drewdle Posted January 13, 2011 Share Posted January 13, 2011 I have a 'user' table and a display users page. How would I display them in alphabetical order by their username? Heres my current basic display page: <?php include 'dbwire.php'; include 'header.php'; $query = mysql_query('SELECT * FROM user'); while ($row = mysql_fetch_array($query)) { echo '<b>Username:</b> ' . $row['user'] . '<br />'; echo '<b>Real Name:</b> ' . $row['name'] . '<br />'; echo '<b>Email:</b> ' . $row['email'] . '<br />'; echo '<b>Location:</b> ' . $row['location'] . '<br /> <hr>'; } ?> Theres also an id row but since user wouldn't be added alphabetically I wouldn't be able to order them by id. Quote Link to comment Share on other sites More sharing options...
litebearer Posted January 13, 2011 Share Posted January 13, 2011 ORDER BY http://www.tizag.com/mysqlTutorial/mysqlorderby.php Quote Link to comment Share on other sites More sharing options...
necken18 Posted January 13, 2011 Share Posted January 13, 2011 $query = mysql_query('SELECT * FROM user ORDER BY user ASC'); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.