RE: [PHP] array help please
| From: | David Freeman | Date: | Sun, 05 Jan 2003 22:35:30 +0000 |
| Subject: | RE: [PHP] array help please | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-130346@lists.php.net to get a copy of this message | ||
> $mysql query1
> result
> array[cityid][cityname]
>
> mysql query2
> result
> array[cityid][cityname]
>
> now what i want to do is kick out any doubles in my array
> and resort them alphebetically by cityname ?!
It's difficult to answer this question without knowing more about the
context and the way you have your database laid out.
In any event, sorting stuff and getting removing duplicates is probably
better achieved in your mysql query than in php.
Something like this would get you close (you'll have to figure it out
for your database as you didn't give much to go on)...
SELECT cityid, DISTINCE(cityname) FROM my_table WHERE some = 'condition'
ORDER BY cityname
Basically, use DISTINCT() to remove duplicates and use ORDER BY to set
the display order.
CYA, Dave