jeudi 6 février 2020

I am trying to store the values of a complex checkbox form in mysql database

I have a multi-part html form and I want to send the data gotten from this form to the database. My issue is with the second step of the form where there are multiple tabs with multiple checkboxes. I am totally confused how to create the schema of this form because of the multiple tabs and many checkboxes. How can I successfully insert the quantity and item name of every category in a well ordered manner that it will be easy for me to get all the records of each entry? Each of the sections have ID (1 to 4) and each item have an itemid.

Here is a link to the form(just for clearity of what I mean. check the step 2 of the form). http://www.diggysmoving.com/get-free-quotes.php

Here is my schema:

CREATE TABLE `moving_entries` (
  `moving_id` int(11) NOT NULL,
  `phone` varchar(15) NOT NULL,
  `full_name` varchar(100) NOT NULL,
  `email` varchar(100) NOT NULL,
  `moving_from` varchar(100) NOT NULL,
  `moving_to` varchar(100) NOT NULL,
  `type_from` varchar(100) NOT NULL,
  `type_to` varchar(100) NOT NULL,
  `living_room_items` text NOT NULL,
  `bedroom_items` text NOT NULL,
  `kichen_items` text NOT NULL,
  `other_items` text NOT NULL,
  `additional_items` text NOT NULL,
  `required _services` text NOT NULL,
  `move_date` varchar(100) NOT NULL,
  `referral_code` varchar(50) NOT NULL,
  `special_instruction` text NOT NULL,
  `created` date NOT NULL,
   PRIMARY KEY (`moving_id`);
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

and below is part of the html code

<tr id="id-inverter4">
  <td class="timesTData text-center" style="vertical-align: middle;" width="15%">
     <span class="opening" style="visibility: hidden;">(</span>
     <span class="digit" style="visibility: hidden">1</span>
     <span class="fa fa-times" style="visibility: hidden;"></span>
     <span class="closing" style="visibility: hidden">)</span>
   </td>
   <td class="nameTData" width="55%" style="vertical-align: middle">Inverter</td>
   <td class="minusTData text-center" style="vertical-align: middle;" width="10%" id="ms-inverter4" data-id="id-inverter4">
     <span class="fa fa-minus fa-lg" style="visibility: hidden;"></span>
   </td>
   <td class="plusTData text-center" style="vertical-align: middle;" width="10%" id="ps-inverter4" data-id="id-inverter4">
     <span class="fa fa-plus fa-lg" style="visibility: hidden;"></span>
   </td>
   <td class="checkTData" width="10%">
     <input type="checkbox" class="form-control checkBox inverter4" name="itemQuantities[]" title="Inverter" data-href="inverter4" data-tr="id-inverter4">
     <input type="checkbox" name="itemIds[]" class="inverter4" value="60" style="display: none;">
     <input type="checkbox" name="sectionIds[]" class="inverter4" value="4" style="display: none;">
   </td>



Aucun commentaire:

Enregistrer un commentaire