Alexander Kleshchevnikov wrote:
Maybe you want this:

while ($data = mysql_fetch_assoc($news)) {
    $sql += "INSERT INTO newtable VALUES ($data['AUS'], $data['id']);\r\n";
}
I seriously recommend using .= on strings instead of +=. += DOES work, that's true, but it's not INTENDED to be used on strings, rather to be used on arrays and numbers.

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/

"John Taylor-Johnston" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]

Can someone help me, show me how to do this please?

1. How do I write $mydata->AUS and $mydata->id into an array?

$authors = array();
while ($mydata = mysql_fetch_object($news))
{
# echo "$mydata->AUS, $mydata->id\n";
??? write to array
}
mysql_close($myconnection);

2. Then I need to create $SQL

foreach ($authors as something)
{
$sql += "INSERT INTO newtable VALUES ($AUS, $id);\r\n";
}

I am reading http://ca3.php.net/manual/en/language.types.array.php but

don't really get it.

Can I do $sql += "blah"; or do I have to write $sql = $sql + "blah";?

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



Reply via email to