// Logic One Using For Loop
<?php
error_reporting(0);
$con=mysql_connect('localhost','root','') or die('Not Connect');
mysql_select_db('multiple',$con);
if (isset($_POST["submit"])){
$field_name = $_POST['values'];
$values = "";
for ($i = 0; $i < sizeof($field_name); $i++) {
$values .= "('".$field_name[$i]."')";
if ($i != sizeof($field_name) - 1) {
$values .= ", ";
}
}
$sql = mysql_query("INSERT INTO php_test VALUES (" . $values.")");
}
}
?>
// Logic Two Using Foreach Loop
<?php
error_reporting(0);
$con=mysql_connect('localhost','root','') or die('Not Connect');
mysql_select_db('multiple',$con);
if (isset($_POST["submit"])){
$field_name = $_POST['values'];
$values = "";
$i=0;
foreach($field_name as $searchval) {
$values.="('".$searchval."')";
if($i!=sizeof($field_name)-1){
$values.=", ";
}
$i++;
}
$query =mysql_query("INSERT INTO php_test VALUES (".$values.")");
}
?>
solved How To Register user Form with all dynamic fields name in php