John, The long expanation is I'm indexing 2000 records to make a list of each author, and which record I can find them in. It's a bibliography thing. I want to do this, but I don't know how to code it:
$array(); $myconnection = mysql_connect($server,$user,$pass); mysql_select_db($db,$myconnection); $news = mysql_query("select id,AUS from $table"); while ($mydata = mysql_fetch_object($news)) { $tempauthors = explode(";", $mydata->AUS); foreach ($tempauthors as $singleauthor) { -------having trouble here-------------- add $singleauthor and $mydata->id to $array -------having trouble here-------------- } } mysql_close; -------having trouble here-------------- foreach ($array as $single_AUS, $single_id) $sql = 'insert into $db.$table2.($single_AUS, $single_id)'; -------having trouble here-------------- mysql_query($sql) It's a little more complicated than that, but advice on coding this much would help. John P.S. my condoleances to New York today. Can't believe it was 3 years ago already. John Holmes wrote: > John Taylor-Johnston wrote: > > 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); > > What do you mean "write to array"?? > > $array = array($mydata->AUS,$mydata->id); > > That? > > > 2. Then I need to create $SQL > > > > foreach ($authors as something) > > { > > $sql += "INSERT INTO newtable VALUES ($AUS, $id);\r\n"; > > } > > += is addition. I doubt that's what you want. > > $sql .= "INSERT INTO newtable VALUES ({$mydata->AUS},{$mydata->id});\r\n"; > > Not sure why you're joining all these queries together, you can only run > one at a time with MySQL... > > -- > > ---John Holmes... > > Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ > > php|architect: The Magazine for PHP Professionals – www.phparch.com -- John Taylor-Johnston ----------------------------------------------------------------------------- "If it's not open-source, it's Murphy's Law." ' ' ' Collège de Sherbrooke: ô¿ô http://www.collegesherbrooke.qc.ca/languesmodernes/ - Université de Sherbrooke: http://compcanlit.ca/ 819-569-2064 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php