Skip to content Skip to sidebar Skip to footer

Make Multiple Inputs In Mysql Table At Once With One Submit Button

I have for example in mysql table: fruit_store id fruit price and I have form like: AddRemove

Solution 1:

use [] in the input name as in here

   <input name='fruit_input[]' .... />

then in php upon receiving post data, loop through

if (is_array($_POST['fruit_input'])){
   foreach ($_POST['fruit_input'] as$key=>$value){
        $price=$_POST['fruit_price'][$key];
        ...

Solution 2:

you need to put some php code to see what fields have are present in the post array use

<?phpif( ! empty( $_POST ) )
{

   $sql = "insert into table  ......values ...";

   mysql_query($sql);

}
?>

to check how many values are present in the post array use

print_r($_POST)

i hope you will understand from here onward.

Post a Comment for "Make Multiple Inputs In Mysql Table At Once With One Submit Button"