Re: Put output of mysql into an Array

From: Date: Sat, 01 Nov 2003 11:26:11 +0000
Subject: Re: Put output of mysql into an Array
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-168261@lists.php.net to get a copy of this message
O.K. When i do this: <? // open database connection $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); // select database mysql_select_db($db) or die ("Unable to select database!"); $query = "SELECT markhow, COUNT(*) FROM prospects GROUP BY markhow"; $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error()); while ($row = mysql_fetch_assoc($result)) { echo $row['markhow']; } O.k. This is working.. Can someone tell me how to retrieve the COUNT function? Regards, Frank ----- Original Message ----- From: "Burhan Khalid" <phplist@meidomus.com> To: "Frank Keessen" <fkeessen@planet.nl>; <php-general@lists.php.net> Sent: Saturday, November 01, 2003 11:59 AM Subject: Re: [PHP] Put output of mysql into an Array > Frank Keessen wrote: > > > Hi, > > > > Can somebody help me with the following? > > > > I want to have the outcome of this: > > > > $query = "SELECT markhow, COUNT(*) FROM prospects GROUP BY markhow"; > > $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error()); > > > > Put into an array like this (for example); > > > > array( > > "January 12" => 52, > > "August 4" => 45 > > ); > > http://www.php.net/mysql-fetch-array > http://www.php.net/mysql-fetch-assoc > > Before asking next time, try reading the manual. :| > > -- > Burhan Khalid > phplist[at]meidomus[dot]com > http://www.meidomus.com > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.general (#168261) next »