Achot: Werte speichern

Beitrag lesen

Danke, aber wie wende ich http://php.net/manual/de/function.reset.php auf mein Beispiel an? Aus dem Beispiel werde ich nicht schlau.

Wenn ich es so mache, habe ich doppelte Einträge

foreach($_POST["adresse"] as $key => $value){
				
	$stmt = $mysqli->prepare("INSERT INTO  adresse (projektID, Nummer, wert)  
                                    VALUES (?, ?, ?)");
						
	$projektID 	= $projektID;
	$Nummer 	= $key;
	$wert		= $value;
						
	$stmt->bind_param("sss", $projektID, $Nummer, $wert);
	$stmt->execute();
			
	
foreach($_POST["userDetails"] as $key => $value){
				
	$stmt = $mysqli->prepare("INSERT INTO  userDetails (projektID, locationID, Nummer, wert)  
                                     VALUES (?, ?, ?, ?)");
						
	$projektID 	= $projektID;
	$locationID     = "xxx";
	$Nummer 	= $key;
	$wert		= $value;
						
	$stmt->bind_param("ssss", $projektID, $locationID, $Nummer, $wert);			
	$stmt->execute();
}}

Alternativ-Text

Vielleicht gibt es auch eine andere Möglichkeit das zu speichern?

<?php for ($i = 1; $i <= $anzahl; $i++) { ?>
<label for="kosten[<?php echo $i;?>]">Kosten</label>
<input type="text" name="kosten[<?php echo $i;?>]" id="kosten_<?php echo $i;?>">
<br>
<label for="auufteilung[<?php echo $i;?>]">Aufteilung</label>
<input type="text" name="auufteilung[<?php echo $i;?>]" id="auufteilung<?php echo $i;?>">
<br>
<?php } ?>

foreach($_POST["adresse"] as $key => $value){
				
	$stmt = $mysqli->prepare("INSERT INTO  adresse (projektID, Nummer, wert)  VALUES (?, ?, ?)");
						
	$projektID 	= $projektID;
	$Nummer 	= $key;
	$wert		= $value;
						
	$stmt->bind_param("sss", $projektID, $Nummer, $wert);
	$stmt->execute();
}	

Dann würde ich einfach meine Tabelle erweitern?