Reply to Re: [PHP] sorting mysql results

Your name:

Reply:


Posted by Andrew Kreps on 10/04/22 11:05

On Mon, 10 Jan 2005 16:38:18 -0500, Sebastian
<sebastian@broadbandgaming.net> wrote:
> 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
>

add order by `type` to your sql statement, and then put something like
the following in your mysql loop:

// initialize $prevType above

if ($prevType !== $row['type'])
{
print "<hr>" . $row['type'] . "------<br>"; // Or whatever you
want the header to look like
}
$prevType = $row['type'];

That should do the trick.

[Back to original 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

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