Dumping MySQL rows into a 2D array
| From: | George Pitcher | Date: | Fri, 13 Dec 2002 15:06:29 +0000 |
| Subject: | Dumping MySQL rows into a 2D array | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-24124@lists.php.net to get a copy of this message | ||
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.