[nycphp-talk] problem with count function
Peter Lehrer
pl at eskimo.com
Fri Jun 6 23:39:11 EDT 2003
thanks
----- Original Message -----
From: "Chris Snyder" <chris at psydeshow.org>
To: "NYPHP Talk" <talk at nyphp.org>
Sent: Friday, June 06, 2003 11:05 PM
Subject: Re: [nycphp-talk] problem with count function
> That's cause mysql_fetch_array creates both indexed (numeric) and
> associative (column names) keys -- so for every column in your result
> set there are actually two keys-- do print_r($row) to see this.
>
> Take a look at mysql_fetch_assoc() in the manual, too, it might be what
> you want.
>
> chris.
>
> Peter Lehrer wrote:
>
> >I noticed when using count() on an array fetched from a mysql db, it
returns
> >twice the amount of elements in the array.
> >
> >For instance:
> ><?
> >$stmt = "SELECT element1,element2,element3,element4,element5 FROM
$table";
> >$sth = mysql_query($stmt, $dbh);
> >
> >$row = mysql_fetch_array($sth);
> >
> >$Count = count($count);
> >?>
> >
> >$Count will equal 10 instead of 5. Has anyone else noticed this
behaviour?
> >
> >--peter
> >
> >
> >
> >
> >
> >
> >
> >
> >
>
>
>
> --- Unsubscribe at http://nyphp.org/list/ ---
>
>
More information about the talk
mailing list