Query in Php/ Mysql Code!!
Hello
can someone please help me, I am trying to add information to a database with checkbox. I have every thing working expect for the checkbox. I am fairly new to the
FORM CODE
<form action="script/test.php" method="post">
<table>
<TD><input type="checkbox" name="fruit[]" id='fruit[]' value='banana'>
banana</TD>
<TD><input type="checkbox" name="fruit[]" id='fruit[]' value='apple'>
Apple</TD>
</tr>
<tr>
<TD></TD>
<TD><input type="checkbox" name="fruit[]" id='fruit[]' value='pine'>
Pineapple</TD>
<TD><input type="checkbox" name="fruit[]" id='fruit[]' value='other'> Other</TD>
<tr></tr>
<tr>
</TABLE></form>
Php code
$con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("test", $con); $sql="INSERT INTO food (Fruit) VALUES ('$_POST[fruit]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "information has been added"; mysql_close($con) ?>



Recent comments
3 days 8 hours ago
4 days 7 hours ago
1 week 3 days ago
1 week 3 days ago
1 week 6 days ago