Dumping MySQL rows into a 2D array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,

I want to grab the resul from a db query and store it in an array so that I
can selectively grab the data later.

This is what I'm doing:

$dbRowCount = mysql_num_rows( $result );
for ($i = 1; $i <= $dbRowCount; ++$i) {
	while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
		$dbRow['ev_id']    = $row["id"];
		$dbRow['ev_uid']   = $row["user_id"];
		$dbRow['ev_title'] = $row["name"];
		$dbRow['ev_cat']   = $row["category"];
		$dbRow['ev_sd']    = $row["start_day"];
		$dbRow['ev_ed']    = $row["end_day"];
	}
}

In my sample database, I have two records which are both found with the
query (tested in MySQLFront) but the array ends up with 3 rows each with the
last record in it.

Any suggestions?

George

===

George Pitcher
HERON Technical Manager
Ingenta plc
23-38 Hythe Bridge Street, Oxford, OX1 2ET
T  +44 (0)1865 799137 direct
T  +44 (0)1865 799000 switchboard
F  +44 (0)1865 799134
E  george.pitcher@ingenta.com

www.ingenta.com
Ingenta: Empowering the exchange of academic and professional content
online.


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux