note 15911 deleted from function.array by irc-html
| From: | irc-html@php.net | Date: | Sat, 19 Jan 2002 20:56:13 +0000 |
| Subject: | note 15911 deleted from function.array by irc-html | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-25439@lists.php.net to get a copy of this message | ||
Form single/muliple checkboxes to SQL. Using and Array..
<?
require("config.inc"); //assume db connect in config
if ($food_array){
for ($i=0;$food_array[$i];$i++){
$sql = "INSERT INTO favorite_food
(foodid, id)
VALUES
(\"foodid\", \"$food_array[$i]\")
";
$result = @mysql_query($sql,$connection) or die("Couldn't execute
query.");
}
}
?>
<FORM METHOD="post" ACTION="<? echo $PHP_SELF?>">
<INPUT TYPE=checkbox NAME=food_array[] value=1> Pizza<br>
<INPUT TYPE=checkbox NAME=food_array[] value=2> Burgers<br>
<INPUT TYPE=checkbox NAME=food_array[] value=3> Hotdogs<br>
<INPUT TYPE="SUBMIT" NAME="submit" VALUE="go">
</FORM>