RE: [PHP] Pulling unique data from database

From: Date: Mon, 02 Feb 2004 02:41:01 +0000
Subject: RE: [PHP] Pulling unique data from database
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-176549@lists.php.net to get a copy of this message
Here's some skeleton code showing one way (untested, no error checking shown): $query = 'SELECT Language FROM whatever'; $result = mysql_query($query); $languages = array(); while ($row=mysql_fetch_object($result)) $languages = array_merge($languages, explode('||', $row->Language)); $languages = array_unique($languages); -- Jonathan Rosenberg President & Founder, Tabby's Place http://www.tabbysplace.org/ > -----Original Message----- > From: Richard Kurth [mailto:rdkurth@directphp.com] > Sent: Sunday, February 01, 2004 9:27 PM > To: php-general@lists.php.net > Subject: [PHP] Pulling unique data from database > > > I am pulling data from a database that list the Language a person > speaks. It is in a format like this. > > English||Spanish > English > English||Portuguese||Finnish > English||Japanese||German > English > English > German > > each time it looks at a new record it list all the languages that that > person speaks with a double pipe in between each language. > > What I need to do is find all the unique languages so I can generate a > list of languages that do not have any repeats in it. so the > list above > would be English,Portuguese,Finnish,Japanese,German,Spanish in any > order > > How would I go about this. I can not change the format of the database > and there are over 200 people listed in the database. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.general (#176549) next »