Jedna tabulka HTML = jedna tabulka v SQL
kazdy radek tabulky = jeden zaznam v DB
cyklem bych chtel projet pole $_POST a kazde 3 hodnoty vlozit do jednoho zaznamu v tabulce.
naky napad?
<form method="POST">
<table>
<tr>
<td><input name="foo1" value="a"></td>
<td><input name="bar1" value="b"></td>
<td><input name="poo1" value="c"></td>
</tr>
<tr>
<td><input name="foo2" value="d"></td>
<td><input name="bar2" value="e"></td>
<td><input name="poo2" value="f"></td>
</tr>
<tr>
<td><input name="foo3" value="g"></td>
<td><input name="bar3" value="h"></td>
<td><input name="poo3" value="i"></td>
</tr>
<input type="submit">
</table>
</form>
<?php
foreach ($_POST as $key => $value){
echo 'key is:' .$key . 'value is: '. $value . '<br>';
if ($key == 'poo1'){
echo 'Toto ma byt jeden zaznam v tabulce <br>';//zde by melo byt neco jako "INSERT INTO $table_name (Column1 , Column2, Column3) VAL('$foo1' , '$bar1' , '$poo1')";
continue;
}
if ($key == 'poo2'){
echo 'Toto ma byt druhy zaznam v tabulce <br>';//zde by melo byt neco jako "INSERT INTO $table_name (Column1 , Column2, Column3) VAL('$foo2' , '$bar2' , '$poo2')";
continue;
}
if ($key == 'poo3'){
echo 'Toto ma byt treti zaznam v tabulce a tak dale... <br>';//zde by melo byt neco jako "INSERT INTO $table_name (Column1 , Column2, Column3) VAL('$foo3' , '$bar3' , '$poo3')";
continue;
}
}
?>