Chris Grigor schrieb:
morning all,

Is there an easier way of doing the following??

form1 submitting to form1.php
<input type="checkbox" name="1">
<input type="checkbox" name="2">
<input type="submit>

form1.php

<?php

$link = mysql_connect('host', 'user', 'pass') or die ("Connection failed:" . mysql_error());

mysql_select_db('yourdbname', $link) or die ("selection failed: " . mysql_error());

if(isset($_POST[1])) {
   mysql_query("INSERT INTO menu (label) VALUES ('item 1 selected')");
   }
else {
   mysql_query("INSERT INTO menu (label) VALUES ('item 1 not selected')");
   }
if(isset($_POST[2])) {
   mysql_query("INSERT INTO menu (label) VALUES ('item 2 selected')");
   }
else {
   mysql_query("INSERT INTO menu (label) VALUES ('item 2 not selected')");
   }

mysql_close($link);
?>

So my question is, if I have a form with 20 + items which can be checkboxes, when submitted do I need to go through each one and add it to the datasbase or maybe some kind of loop?.

Thank you

Chris
SELECT ... INTO
http://dev.mysql.com/doc/refman/4.1/en/ansi-diff-select-into-table.html

--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to