Jump to content
Sign in to follow this  
Murtaza66

insert multiple query into database

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.