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. Link to comment https://forums.phpfreaks.com/topic/224355-display-mysql-info-alphabetically/ 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 Link to comment https://forums.phpfreaks.com/topic/224355-display-mysql-info-alphabetically/#findComment-1159066 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'); Link to comment https://forums.phpfreaks.com/topic/224355-display-mysql-info-alphabetically/#findComment-1159067 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.