<?php
mysql_connect('localhost','root','');
mysql_select_db('filters');
$select_no="";
?>
<!DOCTYPE html>
<html>
<head>
<title> filters program</title>
</head>
<body>
<form method="POST" action="">
Select No. OF Fields <input type="number" style="width:100px;border- radius:10px;" id="selct_no" name="select_no" value=""> To <input type="submit" name="create" id="create_fields" value="create" style="width:70px;border-radius:10px;" onclick="createFields()"> <br><br>
<?php
//IF CONDIOTIN FOR CREATIG ITEMS FIELD depend on user need....
if(isset($_POST['create'])){
$select_no=$_POST['select_no'];
//FOR loop for creating fileds...
// loop for generating given no. of fields...
for ($i=0; $i < $select_no ; $i++) {
global $x;
$x = $i+1;
echo $x.'.) Enter Products Name and Prices.... <br>' ;
echo "<input type='text' style='width:300px; height:25px; border-radius:10px;' placeholder='Enter Items' id='id_item' name='items".$x."' value=''> <input type='text' style='width:100px;height:25px; border-radius:10px;' placeholder='Price' id='id_price' name='price".$x."' value=''> <br/><br/> ";
}
echo " <button name='submit'
style='width:300px;height:25px;border-radius:10px' id='submit_cat'>submit</button>";
echo "<br><No of created fields are ".$x;
}
//if condition for saving data in database table name filters and table name products....
if(isset($_POST['submit'])){
global $x;
for ($a=1;$a<=$x;$a++){
$product=$_POST["items".$a];
$price=$_POST["price".$a];
echo "$product";
echo "$price";
$sql= "INSERT INTO products SET product='$product',price='$price'";
$res=mysql_query($sql);
if ($res) {
echo " data submitted Successfully";
}else{
echo "Not submitted because ".mysql_error();}
}
}
?>
</form>
</body>
</html>
here what i want is that, some buddy please tell me by what concept i'll make populated that information each and every details in my database table
here i provide snapeshot also for your understanding.....this is the first view when we enter value it will creat fields in this image 4 fields are created when we press (create) button after enter 4 in first input field