Re: create and read array

From: Date: Sun, 12 Sep 2004 04:05:25 +0000
Subject: Re: create and read array
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-196432@lists.php.net to get a copy of this message
Alexander Kleshchevnikov wrote:
Maybe you want this: while ($data = mysql_fetch_assoc($news)) {
    $sql += "INSERT INTO newtable VALUES ($data['AUS'], $data['id']);\r\n";
} If you nevertheless want save the data in array you can use a two-dimensional array $authors: $authors = array(); while ($data = mysql_fetch_assoc($news)) {
    $authors[] = array('AUS' => $data['AUS'], 'id' => $data[id]);
} .. foreach ($author in $authors) {
    $sql += "INSERT INTO newtable VALUES ($author['AUS'],
$author['id']);\r\n"; } -- Seigo www.geocities.com/seigo_ua/
Just a note to help the learning process. Either mysql_fetch_assoc() and mysql_fetch_array() will return your result in an array, so you don't need to actually create one. -- Chris Martin Web Developer Open Source & Web Standards Advocate http://www.chriscodes.com/

« previous php.general (#196432) next »