MasterB
17.09.2009, 20:17
Hey, ich hatte mal eine Frage, bzw. ich bräuchte mal eure Hilfe...
ich wollte sowas "lotto"-Artiges Programmieren, hier ist erstmal mein Code.
<form name="lloa" action="lotto2.php" method="post">
<p>LOTTO-ZAHLEN</p>
<p>
<input type="checkbox" name="zahl[]" value="1"> 1<br>
<input type="checkbox" name="zahl[]" value="2"> 2<br>
<input type="checkbox" name="zahl[]" value="3"> 3<br>
<input type="checkbox" name="zahl[]" value="4"> 4<br>
<input type="checkbox" name="zahl[]" value="5"> 5<br>
<input type="checkbox" name="zahl[]" value="6"> 6<br>
<input type="checkbox" name="zahl[]" value="7"> 7<br>
<input type="checkbox" name="zahl[]" value="8"> 8<br>
<input type="checkbox" name="zahl[]" value="9"> 9<br>
<input type="checkbox" name="zahl[]" value="10"> 10<br>
<input type="checkbox" name="zahl[]" value="11"> 11<br>
<input type="checkbox" name="zahl[]" value="12"> 12<br>
<input type="checkbox" name="zahl[]" value="13"> 13<br>
<input type="checkbox" name="zahl[]" value="14"> 14<br>
<input type="checkbox" name="zahl[]" value="15"> 15<br>
<input type="checkbox" name="zahl[]" value="16"> 16<br>
<input type="checkbox" name="zahl[]" value="17"> 17<br>
<input type="checkbox" name="zahl[]" value="18"> 18<br>
<input type="checkbox" name="zahl[]" value="19"> 19<br>
<input type="checkbox" name="zahl[]" value="20"> 20
</p>
<input type="submit" name="formaction" value="Auf gut Glück" />
</form>
<?php
if (isset($_POST['zahl'])) {
reset($_POST['zahl']);
foreach ($_POST['zahl'] as $v) {
print "$v ";
}
} else {
print "Da is was schief gegangen :).";
}
$db = @new mysqli('host', 'name', 'PW', 'DB');
if(mysqli_connect_errno()) {
die ('Connection Lost:'.mysqli_connect_error().'('.mysqli_connect_e rrno().')');
}
$sql ='INSERT INTO Lotto(z1,Datum) VALUES($v,NOW());';
$expo2 = $db->prepare($sql);
$expo2->execute();
$expo2->close();
unset($expo2);
?>
also, das Programm soll eigentlich $v in die Datenbank eintragen...Problem ist aber...es macht nich das was es soll. :(
Ich glaube ich habe bei dem Part
$sql ='INSERT INTO Lotto(z1,Datum) VALUES($v,NOW());';
$expo2 = $db->prepare($sql);
$expo2->execute();
$expo2->close();
unset($expo2);
etwas falsch gemacht. Weis es aber nicht genau. Währe nett wenn mir wer helfen könnte das Problem zu lösen. Fals, dann bitte ich auch um eine erklärung. Danke im vorraus.
ich wollte sowas "lotto"-Artiges Programmieren, hier ist erstmal mein Code.
<form name="lloa" action="lotto2.php" method="post">
<p>LOTTO-ZAHLEN</p>
<p>
<input type="checkbox" name="zahl[]" value="1"> 1<br>
<input type="checkbox" name="zahl[]" value="2"> 2<br>
<input type="checkbox" name="zahl[]" value="3"> 3<br>
<input type="checkbox" name="zahl[]" value="4"> 4<br>
<input type="checkbox" name="zahl[]" value="5"> 5<br>
<input type="checkbox" name="zahl[]" value="6"> 6<br>
<input type="checkbox" name="zahl[]" value="7"> 7<br>
<input type="checkbox" name="zahl[]" value="8"> 8<br>
<input type="checkbox" name="zahl[]" value="9"> 9<br>
<input type="checkbox" name="zahl[]" value="10"> 10<br>
<input type="checkbox" name="zahl[]" value="11"> 11<br>
<input type="checkbox" name="zahl[]" value="12"> 12<br>
<input type="checkbox" name="zahl[]" value="13"> 13<br>
<input type="checkbox" name="zahl[]" value="14"> 14<br>
<input type="checkbox" name="zahl[]" value="15"> 15<br>
<input type="checkbox" name="zahl[]" value="16"> 16<br>
<input type="checkbox" name="zahl[]" value="17"> 17<br>
<input type="checkbox" name="zahl[]" value="18"> 18<br>
<input type="checkbox" name="zahl[]" value="19"> 19<br>
<input type="checkbox" name="zahl[]" value="20"> 20
</p>
<input type="submit" name="formaction" value="Auf gut Glück" />
</form>
<?php
if (isset($_POST['zahl'])) {
reset($_POST['zahl']);
foreach ($_POST['zahl'] as $v) {
print "$v ";
}
} else {
print "Da is was schief gegangen :).";
}
$db = @new mysqli('host', 'name', 'PW', 'DB');
if(mysqli_connect_errno()) {
die ('Connection Lost:'.mysqli_connect_error().'('.mysqli_connect_e rrno().')');
}
$sql ='INSERT INTO Lotto(z1,Datum) VALUES($v,NOW());';
$expo2 = $db->prepare($sql);
$expo2->execute();
$expo2->close();
unset($expo2);
?>
also, das Programm soll eigentlich $v in die Datenbank eintragen...Problem ist aber...es macht nich das was es soll. :(
Ich glaube ich habe bei dem Part
$sql ='INSERT INTO Lotto(z1,Datum) VALUES($v,NOW());';
$expo2 = $db->prepare($sql);
$expo2->execute();
$expo2->close();
unset($expo2);
etwas falsch gemacht. Weis es aber nicht genau. Währe nett wenn mir wer helfen könnte das Problem zu lösen. Fals, dann bitte ich auch um eine erklärung. Danke im vorraus.