Jump to content

Sort alphabetically


anabeli

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.