Ok I have to learn how to do it.
For now I just fix the last comma error.
My Idea is learn how to do it after with staments,
<?php
$i=0;
foreach ($_POST as $k=>$v) {
++$i;
}
$count=$i-1;
$count_data=$i-2;
echo "\$sql= INSERT INTO apolices(";
$z=0;
foreach ($_POST as $variable_name=>$variable_data) {
++$z;
if($variable_name=="submit"){
$variable_name="";
}if($z<$count){
echo($variable_name).',';
}else{
echo($variable_name);
}
}
$x=0;
echo ")" . "Values (";
foreach ($_POST as $variable_name=>$variable_data){
++$x;
if($variable_data==""){
$variable_data="NULL";
}if($x<$count_data){
echo($variable_data).',';
}if($x==$count){
echo($variable_data);
}
}echo ")";
?>