Hello Bart,

Tuesday, January 6, 2004, 12:40:38 PM, you wrote:

BK> This scripts works, but.. my desire is now to be able to sort the
BK> output, wich is generated by the 'while' loop, for instance on 'name',
BK> or on 'surname' . sort(), ksort()? I couldn't understand the 
BK> explanations i found (and so declared myself as newbie :)

It's probably a lot easier to sort the data at the SQL level rather
than messing around with your array.

For example:

$result = mysql_query(
"SELECT id, name, surname, address FROM addresses ORDER BY name DESC");

Will list by name alphabetically (A-Z), change to "ASC" for Z-A).
You can also order by two fields at once:

$result = mysql_query(
"SELECT id, name, surname, address FROM addresses ORDER BY name DESC,
surname DESC");

Or some selective sorting:

$result = mysql_query(
"SELECT id, name, surname, address FROM addresses WHERE name LIKE 'a%'
ORDER BY name DESC");

Will list all names starting with the letter A, in alphabetical order.

-- 
Best regards,
 Richard                            mailto:[EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to