ausgezeichnete Posted May 7, 2009 Share Posted May 7, 2009 i have those three arrays for example $num=array(1,2,3); $name=array('one','two','three'); $letter=array('m','k','n'); what i want is to loop through all of them and insert them like that: insert into mydb (field1,field2.field3) values(1,'one','m'); Link to comment https://forums.phpfreaks.com/topic/157211-merge-3-arrays-to-insert-in-one-row-in-db/ Share on other sites More sharing options...
Jibberish Posted May 7, 2009 Share Posted May 7, 2009 Well if you can guarantee that they will always be in the right order relative to each other, and be the same size. <?php for($i = 0; $i<sizeof($array1); $i++) { $sql = 'INSERT INTO tableName (column1, column2, column3) VALUES (' . $array1[$i] . ',' . $array2[$i] . ',' . $array3[$i] . ')'; mysql_query($sql); } ?> Link to comment https://forums.phpfreaks.com/topic/157211-merge-3-arrays-to-insert-in-one-row-in-db/#findComment-828438 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.