NYCPHP Meetup

NYPHP.org

[nycphp-talk] problem with count function

Chris Snyder chris at psydeshow.org
Fri Jun 6 23:05:28 EDT 2003


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