DamienRoche Posted September 9, 2008 Share Posted September 9, 2008 I'm having trouble inserting the exact array of data from one mysql table into another. so say I have two columns and 3 rows: name || email ----------------- name1 || email1 name2 || email2 name3 || email3 ______________ How do I transfer that exact data from one table to another using php? Thanks. Link to comment https://forums.phpfreaks.com/topic/123390-solved-transfer-array-of-data-from-1-mysql-table-to-another-php/ Share on other sites More sharing options...
vbnullchar Posted September 9, 2008 Share Posted September 9, 2008 something like this insert into table1 (select * from table2) Link to comment https://forums.phpfreaks.com/topic/123390-solved-transfer-array-of-data-from-1-mysql-table-to-another-php/#findComment-637304 Share on other sites More sharing options...
burn1337 Posted September 9, 2008 Share Posted September 9, 2008 Well you can loop it, or you can do it all at once, I would start with getting the rows into arrays $string = 'select col1 col2 from tbl_name' $query = mysql_query($string); $row = 1; //or number of first row $col= 1; //or whatever colum number is name $get = mysql_result($query, $row, $col); $string2 = "select * from tbl_name where name='$get'"; $array1 mysql_fetch_arrar(); $string3 = "insert into tbl_name(name, email) values('$array1[0]', '$array[1]')"; $query2 = mysql_query($string3); That might work.. just as a brain stormer at least. vbnullchar apparently has a much easier way though lol Link to comment https://forums.phpfreaks.com/topic/123390-solved-transfer-array-of-data-from-1-mysql-table-to-another-php/#findComment-637308 Share on other sites More sharing options...
vbnullchar Posted September 9, 2008 Share Posted September 9, 2008 something like this insert into table1 (select * from table2) just make sure they have same field count/properties Link to comment https://forums.phpfreaks.com/topic/123390-solved-transfer-array-of-data-from-1-mysql-table-to-another-php/#findComment-637309 Share on other sites More sharing options...
DamienRoche Posted September 9, 2008 Author Share Posted September 9, 2008 Thanks guys! That combined effort has relieved another one of my php woes.. Thanks. Link to comment https://forums.phpfreaks.com/topic/123390-solved-transfer-array-of-data-from-1-mysql-table-to-another-php/#findComment-637310 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.