 <pre><code>$sql=array(); foreach ($f_list as $list) { //This assumes, your values are already safely quoted $sql[]="'".$list['id']."','".$list['name']."'"; } $sql=implode('),(',$sql); $sql="INSERT INTO tablename VALUES($sql)"; // now run the query </code></pre>