this is the sort of thing I usually do ...
$result = mysql_query($db, "SELECT * FROM filename...")
while ($array = mysql_fetch_array($result)) $category[$array["category"]][]
= $array["title"];
foreach ($category as $cat=>$title_array)
{ echo("Category $cat<br>");
foreach ($title_array as $title) echo(" - $title<br>");
}
a lot simpler and you don't have to worry about any start and end
conditions. This can also be extrapolated to more complex situations, e.g.
where $title contains more than just a name you can do sub totals of "title"
quantities by category, or whatever.
Tim Ward
Senior Systems Engineer
Please refer to the following disclaimer in respect of this message:
http://www.stivesdirect.com/e-mail-disclaimer.html
> -----Original Message-----
> From: David Robley [mailto:[EMAIL PROTECTED]]
> Sent: 11 July 2001 02:17
> To: Frédéric Mériot; PHP General List
> Subject: Re: [PHP] How to fetch a "group by" Query?
>
>
> 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
> > -bibi
> > -nini
> > -fififi
> >
> > Categorie C
> > -titi
> > -toto
> > -tutu
> >
> > ... etc
> >
> > With cold fusion (for those who know) I want to do the same as
> > <CFOUTPUT QUERY="myquery" GROUP="categorie">
> >
> > Thanks
>
> Select category, description from table where whatever order
> by category,
> description
>
> Then when you display the rows, keep track of the current and
> previous
> value of $description; if it changes, print the new value.
>
> --
> David Robley Techno-JoaT, Web Maintainer, Mail List Admin, etc
> CENTRE FOR INJURY STUDIES Flinders University, SOUTH AUSTRALIA
>
> Don't stop posting, a good laugh breaks up my day nicely
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]