Evert wrote: > Hi all! > > What is the best/easiest way to use PHP to move a selection of MySQL > records from one table to another table, which is in the same database > and which has the same structure as the first table?
Advertising
here's a stab at it (not tested): $ids_to_get(1,3,5,6,8); $q=mysql_query( 'select * from from_table where id="'.join('" or id="',$ids_to_get).'"' ); while($r=mysql_fetch_array($q)){ $fields=array(); foreach($r as $k=>$v)$fields[]='`'.$k.'`="'.addslashes($v); echo('insert into to_table set '.join(',',$fields).'<br />'); # mysql_query('insert into to_table set '.join(',',$fields)); }obviously, first try the above to make sure the SQL looks right, before you uncomment the line that does the damage
Kae -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php