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'); etc..
This should get you started on the right track. $num=array(1,2,3); $name=array('one','two','three'); $letter=array('m','k','n'); while ($value = current($num)) { $pos = key($num); $sql = "insert into mydb (field1,field2.field3) values($value,'$name[$pos]','$letter[$pos]')"; echo $sql; // Action the sql here using mysql_query($sql) or whatever. next($num); } PHP:
Yeah my Dear you can do this in php Let's look how to do this. $i=0; while($i<3) { $query="insert into yourtable values('$num[$i]','$name[$i]','$letter[$i]')"; $result=mysql_query($query); $i=$i+1; } if($result) { echo "Records Successfully Entered"; } else{ echo mysql_error(); } This code will do what you want. Happy Coding...!