RE: [PHP-DB] Array sorting question...

From: Date: Fri, 23 Jan 2004 20:23:11 +0000
Subject: RE: [PHP-DB] Array sorting question...
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-32604@lists.php.net to get a copy of this message
NIPP, SCOTT V (SBCSI) wrote: > I am trying to populate an array from a MySQL database. I think I > have the code correct to populate the array, but I need to somehow > sort the array eliminating duplicate values. I think I can loop > through the array doing a comparison and building a new array by > discarding the value if it is a duplicate, but I was not sure if > there was a more efficient way of doing this. You can ask for only unique values to be returned in the database result. Try something like this: $sql = "SELECT UNIQUE username FROM table WHERE where_clause ORDER BY username"; Katie Dewees Web Developer/PHP Programmer kdewees@bellsouth.net http://www.evans-young.com

« previous php.db (#32604) next »