ChrisB: Variable Anzahl an identischen Inserts aus Formular heraus

Beitrag lesen

Hi,

if ($_POST['times'] == NULL)
   {$times = array_keys(1)} else {$times = array_keys($_POST['times'])
$sql = "INSERT INTO table ( title, content) VALUES
foreach ($times) {
  ("".$_POST['title']."", "".$_POST['content']."")
  }
";

Wenn "times" 0 ist soll der Eintrag nur 1 mal erfolgen. Das "array_keys" ist sicher völlig falsch, hab ich woanders kopiert.

Schon das foreach ist an dieser Stelle voellig falsch - weil du dich an der Stelle in einem Textstring befindest, und da sind das eben nur die Buchstaben f, o, r, e, a, c und h hintereinander als Stringinhalt.

Wenn dir also noch Grundwissen ueber Umgang mit Strings fehlt, dann schlage ich vor, du faengst hier an zu lesen:
http://www.php.net/manual/en/language.types.string.php

MfG ChrisB

--
„This is the author's opinion, not necessarily that of Starbucks.“