Murtaza66 Posted March 5, 2015 Share Posted March 5, 2015 Hello guys, I have a question about how to insert a multiple query into database i have the following html form <div class="input_fields_wrap"> <button id="remove_field">x</button> <?php $query = mysql_query("SELECT * FROM producten"); ?> <select name="Producten[]" id="Producten"> <div><?php while($row = mysql_fetch_array($query)){ echo "<option>" . $row['Producten'] . "</option>"; }?> </div><input type="text" name="ProdOms[]"> <input type="text" size="3" name="Aantal[]"> <input type="text" size="3" name="Prijs[]"> <a href="javascript:void(0)" onclick="toggle_visibility('popup-box1');"><img src="../img/icons/info.png" height="16" width="16"></a> </select> </div> So this is the html form what I'm using i have 15 of these. It deppents how much the user would like too use for example he/she want to use 2 form like this fill it in and insert into the database. Quote Link to comment Share on other sites More sharing options...
Murtaza66 Posted March 5, 2015 Author Share Posted March 5, 2015 foreach($_POST['Producten'] as $row=>$data){ $Producten = mysql_real_escape_string($data); $ProdOms = mysql_real_escape_string($_POST['ProdOms'][$row]); $Aantal = mysql_real_escape_string($_POST['Aantal'][$row]); $Prijs = mysql_real_escape_string($_POST['Prijs'][$row]); $row_data[] = "('$Producten','$ProdOms','$Aantal','$Prijs')"; //var_dump("INSERT into hulptabel (ID, FactuurNR, Product,ProdOms,Aantal, Prijs) VALUES ('$ID','$FactuurNR' ,'$Producten','$ProdOms','$Aantal','$Prijs')"); $sql= mysql_query("INSERT into hulptabel (ID, FactuurNR, Product,ProdOms,Aantal, Prijs) VALUES ('$ID','$FactuurNR' ,'$Producten','$ProdOms','$Aantal','$Prijs')"); } } this is the php script what I have know ps. why show var_dump at the good way i.e two query's en mysql_query not Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.