Instead of trying to sort the result AFTER it returns from the query, you
could use an ORDER BY clause in your query to sort the results prior to
trying to output it?

You could change your query to something like:

"SELECT * FROM tablename ORDER BY fieldname"

HTH

Sam Masiello
Software Quality Assurance Engineer
Synacor
(716) 853-1362 x289
[EMAIL PROTECTED]

 -----Original Message-----
From:   Allen May [mailto:[EMAIL PROTECTED]]
Sent:   Thursday, August 16, 2001 11:32 AM
To:     [EMAIL PROTECTED]
Subject:        [PHP] Sort a an array?

I want to sort a result set from a mySQL query (see code below).
I can't figure out how to properly sort the $result in the while loop.

I just want to alphabatize the search result.

Any suggestions how to do this?

Thanks

-Allen
[EMAIL PROTECTED] (remove _nospam to reply)

*************************************************************************

$query = "select * from $table";
$result = mysql_query($query);

print "<form name=\"JobDesc\" method=\"post\" action=\"jobdesc.php\">\n";

print "<select name=\"wilber\">\n";
while ($row = mysql_fetch_array($result)) :
   print "<option value=\"";
   print $row["Jobtitle"];
   print "\">";
   print $row["Jobtitle"];
   print "</option>\n";
endwhile;


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to