anabeli Posted March 22, 2009 Share Posted March 22, 2009 Hi everyone, How can I sort my resulting table alphabetically by my variable $pf_surname: function getField($profile_data) { $db = mysql_select_db("idaworld_net") or die ("Couldn't select database"); $query = "SELECT * FROM phpbb_profile_fields_data"; $result = mysql_query($query) or die ("Couldn't exectute query"); /** Display results in a table **/ echo "<h1>Members</h1>"; echo "<table width='95%' align='center' cellspacing='0'>"; echo "<tr><td colspan='2'><hr /></td></tr>"; while ( $row = mysql_fetch_array($result)) { extract($row); echo "<tr>\n <td><strong>$pf_surname $pf_first_name</strong></div></td>\n <tr>\n <td>$pf_inst_affil</td></tr>\n <tr>\n <td>$pf_town_city, $pf_country</td></tr>\n <tr>\n <td><em>Research interests:</em> $pf_research_int</td><tr>\n <tr>\n <td><em>Publications:</em> $pf_publications</td></tr>\n <tr>\n <td><em>Personal Webpage:</em> $pf_webpage</td></tr>\n"; echo "<tr><td colspan='2'><hr /></td></tr>\n"; } echo "</table>\n"; } Thanks for your help! Link to comment https://forums.phpfreaks.com/topic/150613-sort-alphabetically/ Share on other sites More sharing options...
trq Posted March 22, 2009 Share Posted March 22, 2009 SELECT * FROM phpbb_profile_fields_data ORDER BY pf_first_name ASC Link to comment https://forums.phpfreaks.com/topic/150613-sort-alphabetically/#findComment-791139 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.