Datenbank eintragen

Dolphon

Erfahrenes Mitglied
Moin.

WIe schaff ich es, das das Skript in die Tabelle "test" geht.
Dort befinden sich nun 10 Zeilen. Jede Zeile hat 3 Spalten(Id, Name, Ort)
Nun will ich per Eingabe skript in jede Zeile und Spalte etwas hineinschreiben.
Und wenn ich das skript abschicke alles eingetragen ist.
FÜr eine einzelne Zeile schaffe ich das, aber nicht 10 auf einmal.

MFG

Dolphon
 
Sowas?
PHP:
$query = array('UPDATE ...', 'UPDATE ...', '...');
$x = 0;
while($query[$x])
{
mysql_query($query[$x])
$x++;
}
 
versteh ich nicht so ganz.

Vorallem wie soll ich das mit dem Java Part amchen:

PHP:
<form action="eingabe.php" method="post" name="FormName" onSubmit="return chkFormular();" ENCTYPE="multipart/form-data">
Bitte nur die Film ID`s und Bildnummern eingeben!
<br>
<br>
<b>Platz 1</b><br>Film ID:
<input type=text name="platz1" size="10"> Bildnummer:
<input type=text name="bild1" size="10">
<br>
<br>
<b>Platz 2</b> <br>Film ID:
<input type=text name="platz2" size="10">Bildnummer:
<input type=text name="bild2" size="10">
<br>
<br>
<b>Platz 3</b> <br>Film ID:
<input type=text name="platz3" size="10">Bildnummer:
<input type=text name="bild3" size="10">
<br>
<br>
<b>Platz 4</b> <br>Film ID:
<input type=text name="platz4" size="10">Bildnummer:
<input type=text name="bild4" size="10">
<br>
<br>
<b>Platz 5</b> <br>Film ID:
<input type=text name="platz5" size="10">Bildnummer:
<input type=text name="bild5" size="10">
<br>
<br>
<b>Platz 6</b> <br>Film ID:
<input type=text name="platz6" size="10">Bildnummer:
<input type=text name="bild6" size="10">
<br>
<br>
<b>Platz 7</b><br>Film ID:
<input type=text name="platz7" size="10">Bildnummer:
<input type=text name="bild7" size="10">
<br>
<br>
<b>Platz 8</b><br>Film ID:
<input type=text name="platz8" size="10">Bildnummer:
<input type=text name="bild8" size="10">
<br>
<br>
<b>Platz 9</b> <br>Film ID:
<input type=text name="platz9" size="10">Bildnummer:
<input type=text name="bild9" size="10">
<br>
<br>
<b>Platz 10</b> <br>Film ID:
<input type=text name="platz10" size="10">Bildnummer:
<input type=text name="bild10" size="10">
<br>
<br>



<input type=submit value=" Top 10 eintragen ">
<input type="hidden" name="formstat" value="1">
</form>
</body>
 
Hallo, so könnte es in etwa aussehen:

Das Formular:
Code:
<form action="eingabe.php" method="post" name="FormName" onSubmit="return chkFormular();" ENCTYPE="multipart/form-data">
<br><br><b>Platz 1</b><br>Film ID:
<input type=text name="platz[]" size="10"> Bildnummer:
<input type=text name="bild[]" size="10">
<br><br><b>Platz 2</b><br>Film ID:
<input type=text name="platz[]" size="10"> Bildnummer:
<input type=text name="bild[]" size="10">
<br><br><b>Platz 3</b><br>Film ID:
<input type=text name="platz[]" size="10"> Bildnummer:
<input type=text name="bild[]" size="10">
<br><br><b>Platz 4</b><br>Film ID:
<input type=text name="platz[]" size="10"> Bildnummer:
<input type=text name="bild[]" size="10">
<br><br><b>Platz 5</b><br>Film ID:
<input type=text name="platz[]" size="10"> Bildnummer:
<input type=text name="bild[]" size="10">
<br><br><b>Platz 6</b><br>Film ID:
<input type=text name="platz[]" size="10"> Bildnummer:
<input type=text name="bild[]" size="10">

<!-- usw. ... -->

<input type=submit value=" Top 10 eintragen ">
<input type="hidden" name="formstat" value="1">
</form>

und das verarbeitende Script (eingabe.php):
PHP:
<?php

  // ...

  $platz = $_POST['platz'];
  $bild  = $_POST['bild'];
  
  for ($x = 0; $x < count($platz); $x++) {
    mysql_query("INSERT INTO test (platz, bild) values(".$platz[$x].", ".$bild[$x].")");
  }
  
  // ...

?>

mfg, snuu
 
Habs sogemacht wie du es obne angegeben hast.
er spuckt kein e Fehlermeldung aus, allerdigns trägt er nichts ein.

PHP:
<?
### Konfigurationsdatei einlesen
require("config.inc.php");
	
### Eintragen der TOp 10 in die Datenbank
if($formstat == TRUE)
{
 $db = mysql_connect($db_host, $db_user, $db_pass);
 mysql_select_db($db_name);


 $platz = $_POST['platz'];
  $bild  = $_POST['bild'];
  
  for ($x = 0; $x < count($platz); $x++) {
    mysql_query("INSERT INTO top10 (platz, bild) values(".$platz[$x].", ".$bild[$x].")");
  }



 mysql_close($db);
 
 echo "<br><br><strong>Die Top 10 DAten wurden erfolgreich in die Datebank eingetragen!</strong><br><br>"; 

 }

?>

<form action="eingabe.php" method="post" name="FormName" onSubmit="return chkFormular();" ENCTYPE="multipart/form-data">
Bitte nur die Film ID`s und Bildnummern eingeben!
<br>
<br>
<b>Platz 1</b><br>Film ID:
<input type=text name="platz[]" size="10"> Bildnummer:
<input type=text name="bild[]" size="10">
<br>
<br>
<b>Platz 2</b> <br>Film ID:
<input type=text name="platz[]" size="10">Bildnummer:
<input type=text name="bild[]" size="10">
<br>
<br>
<b>Platz 3</b> <br>Film ID:
<input type=text name="platz[]" size="10">Bildnummer:
<input type=text name="bild[]" size="10">
<br>
<br>
<b>Platz 4</b> <br>Film ID:
<input type=text name="platz[]" size="10">Bildnummer:
<input type=text name="bild[]" size="10">
<br>
<br>
<b>Platz 5</b> <br>Film ID:
<input type=text name="platz[]" size="10">Bildnummer:
<input type=text name="bild[]" size="10">
<br>
<br>
<b>Platz 6</b> <br>Film ID:
<input type=text name="platz[]" size="10">Bildnummer:
<input type=text name="bild[]" size="10">
<br>
<br>
<b>Platz 7</b><br>Film ID:
<input type=text name="platz[]" size="10">Bildnummer:
<input type=text name="bild[]" size="10">
<br>
<br>
<b>Platz 8</b><br>Film ID:
<input type=text name="platz[]" size="10">Bildnummer:
<input type=text name="bild[]" size="10">
<br>
<br>
<b>Platz 9</b> <br>Film ID:
<input type=text name="platz[]" size="10">Bildnummer:
<input type=text name="bild[]" size="10">
<br>
<br>
<b>Platz 10</b> <br>Film ID:
<input type=text name="platz[]" size="10">Bildnummer:
<input type=text name="bild[]" size="10">
<br>
<br>



<input type=submit value=" Top 10 eintragen ">
<input type="hidden" name="formstat" value="1">
</form>
 
Hallo, probier mal statt
PHP:
if($formstat == TRUE)
das hier:
PHP:
if($_POST['formstat'] == 1)
Kann sein, dass bei Dir register_globals auf off steht.

mfg, snuu
 
Kann sein, dass bei Dir register_globals auf off steht.
Und das sollte auch so sein und auch so bleiben. Also nicht auf die dumme Idee kommen, aus Bequemlichkeitsgründen, das einfach auf on zu stellen, nur damit man nichts im Script ändern muss.
 
habs ausprobiert, aber es klappt nicht.

Ich hab schonmal gehört warum register_globals auf off steht, habs aber wieder vergessen. Darum sag es mir bitte nochmal.
 
Zurück