You are here: Re: [PHP] sorting mysql results « PHP « IT news, forums, messages
Re: [PHP] sorting mysql results

Posted by Leon Poon on 10/04/89 11:05

Sort when querying from database:

SELECT name, type FROM some_table ORDER BY type ASC, name ASC


----- Original Message -----
From: "Sebastian" <sebastian@broadbandgaming.net>
To: <php-general@lists.php.net>
Sent: Tuesday, January 11, 2005 5:38 AM
Subject: [PHP] sorting mysql results


>I have a list of rows in the database and i would like to sort them in two
> categories.
> example,
>
> echo $row['name'] . '-' . $row['type'];
>
> // output:
>
> row 1 - files
>
> row 2 - files
>
> row 3 - music
>
> row 4 - files
>
> I would like this output:
>
> files
> ----------
> row 1 - files
> row 2 - files
> row 4 - files
>
> music
> -----------
> row 3 - music
>
> if the $row['type'] is music i want to output an <hr> and the results
> below
> it but below the files results.. makes sense?
> i thought i remember doing this once using a dummy var but cant remember
> how. i guess i could always run a second query, but would like to avoid
> that.
>
> thanks for any help.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация