i need some advise on how to copy multiple row with mysql and php
first way i can think of is sql statement as below
Code: Select all
INSERT INTO [i]table [/i](column1, column3) SELECT column2, column4 FROM [i]table2 [/i]second way maybe as below?
Code: Select all
$sql = "SELECT * FROM [i]table1[/i]";
$result = mysql_query($sql, $db);
while($row = mysql_fetch_assoc($result)){
$sql2 = "INSERT INTO [i]table1[/i](column1, column2) VALUE ($row['name'], $row['phone']);
$result2 = mysql_query($sql2,$db);
}