Re: [SLUG] PHP MySQL question.

From: Jay Wineinger (shad@wnoc.com)
Date: Tue Apr 01 2003 - 22:08:08 EST


You might try assigning the count to another name "SELECT cats, COUNT(cats)
AS cat_count ...."

Jay

----- Original Message -----
From: "SpamFree" <SpamFree@tampabay.rr.com>
To: <slug@nks.net>
Sent: Tuesday, April 01, 2003 1:07 PM
Subject: [SLUG] PHP MySQL question.

> The following code snippet works fine. The WHILE statement returns true:
>
> > $catsquery = "SELECT cats, COUNT(cats) FROM data_tbl GROUP BY cats";
> > $getcats = mysql_query($catsquery) or die ("Boom!!");
> >
> > while ($catsarray = mysql_fetch_array($getcats))
> > {
> > //do stuff
> > }
> >
> //snip
>
> But, if I use the MYSQL_ASSOC option it fails. The WHILE statement returns
> false:
>
> > $catsquery = "SELECT cats, COUNT(cats) FROM data_tbl GROUP BY cats";
> > $getcats = mysql_query($catsquery) or die ("Boom!!");
> >
> > while ($catsarray = mysql_fetch_array($getcats, MYSQL_ASSOC))
> > {
> > //do stuff
> > }
> >
> //snip
>
> Can anyone tell me why this second snippet fails? The query can return a
lot
> of records so, I want to create the array by association rather than both
> association and numeric index, as the first snippet does. You know, memory
> and all that.
>
> Any help is greatly appreciated.
>



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 17:53:31 EDT