object/array with repeating values

From: Date: Wed, 21 Feb 2001 01:20:28 +0000
Subject: object/array with repeating values
Groups: php.general 
Request: Send a blank email to php-general+get-40867@lists.php.net to get a copy of this message
I'm make an object or an array from the results of a query to my MySQL database. The value returned is entered in <option>s and any repeated values are unwanted. Is there a way to remove them easily? eg. <select> <? $qid = mysql_query("SELECT this FROM that WHERE here"); while ($r = mysql_fetch_object($qid)) { ?> <option><?=$r->this?></option> <? } ?> </select> I was thinking of creating an array before the while, then in the while add each "$r->this" if "(! in_array($arr))". Then I would have to do another while with the <option> included. But I'm not really sure how to add elements to existing arrays. And that might not even be the best way. Any iteas?

« previous php.general (#40867) next »