Note that there are some explanatory texts on larger screens.

plurals
  1. POStoring value of second checkbox in MySQL
    primarykey
    data
    text
    <p>I've tried finding an answer for this - and I expect it's going to be very easy to fix.</p> <p>I have an HTML form with a list of events, each of which has a tick box (<code>name="registrations[]"</code> and an ID pulled from the database as the value). A customer can tick as many boxes as they want to indicate whether they want to attend.</p> <p>Alongside each event is a second tick box (<code>name="lunch[]"</code>), which a customer can use to indicate whether they require lunch at that event.</p> <p>Now, I'm able to insert multiple events into the database using:</p> <pre><code>foreach ($_POST['registrations'] as $registration) { /// do database work } </code></pre> <p>(with <code>$registration</code> used to store the event ID for every booking).</p> <p>My question is this: how would I go about storing the value of that second checkbox in the database? Thanks, as always, for your help.</p> <p>Edit - database schema, as requested:</p> <pre><code>CREATE TABLE IF NOT EXISTS `bookings2` ( `booking_id` int(5) unsigned zerofill NOT NULL AUTO_INCREMENT, `contact` varchar(150) NOT NULL DEFAULT '', `company` varchar(150) NOT NULL DEFAULT '', `service` varchar(50) NOT NULL DEFAULT '', `telephone` varchar(50) NOT NULL DEFAULT '', `email` varchar(150) NOT NULL DEFAULT '', `website` varchar(250) NOT NULL DEFAULT '', `address` text NOT NULL, `cars` char(2) DEFAULT NULL, `size` varchar(10) DEFAULT NULL, `advertising` varchar(15) NOT NULL DEFAULT '', `display` char(3) DEFAULT NULL, `bag` char(3) DEFAULT NULL, `lunch` char(3) DEFAULT NULL, `masterclass` char(3) DEFAULT NULL, `other_info` text, `promo_code` varchar(50) NOT NULL, `electric` char(3) DEFAULT NULL, `event_id` varchar(100) NOT NULL DEFAULT '', `booking_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (`booking_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=104 ; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload