Couldn't you just do something like:
?
$rows = mysql_query(SELECT * FROM table ORDER BY category, title);
while ($row = mysql_fetch_array($rows)) {
if ($row[title] $last)
print b$row[category]/bbr\r\n;
print li$row[title]/libr\r\n;
$last = $row[title];
}
?
/* Chris Lambert,
Hello (again)
I've got a query which extract titles and categories with a group by on the
categorie. Is there a simple way to display rows like this (without doing a
second query ):
Categorie A
-titi
-toto
-tutu
Categorie B
-bibi
-nini
-fififi
Categorie C
-titi
Did you try 'SELECT categorie,item FROM your_table GROUP BY categorie'?
Ben
-Original Message-
From: Frédéric Mériot [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 10, 2001 5:41 AM
To: PHP General List
Subject: [PHP] How to fetch a group by Query?
Hello (again)
I've got a query which
On Tue, 10 Jul 2001 22:10, Frédéric Mériot wrote:
Hello (again)
I've got a query which extract titles and categories with a group by on
the categorie. Is there a simple way to display rows like this (without
doing a second query ):
Categorie A
-titi
-toto
-tutu
Categorie B
4 matches
Mail list logo