View Single Post
  #1 (permalink)  
Old July 5th, 2005, 10:41 AM
jkilgore jkilgore is offline
Registered User
 
Join Date: Jul 2005
Location: , , USA.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Store Checkbox values in MySQL Database

I need to know how to take multiple selections from a series of checkboxes and put those values into MySQL. I'm not interested in the easiest way, but the most efficient. I've researched this for several days and I know about serialize and unserialize, but If I'm not mistaken the values stored will not be searchable. I need to make sure they can still be searched. My questions are these. What data type should I use in MySQL for these values (Tiny INT/ENUM)? Also, how should I set up the form to take those values and pass them to MySQL? Should I set it up so that each checkbox has a different name, set the value to 1 and checked. What code do I need to pass those values to MySQL. My current checkbox code is as follows:

<tr>
      <td width="255"><span class="style2">
        <input type="checkbox" name="service[]" value="cleaning">CLEANING</span></input></td>
      <td width="254"><span class="style2">
    <input type="checkbox" name="service[]" value="linens">LINENS</span></input></td>
    </tr>

    <tr>
      <td><span class="style2">
        <input type="checkbox" name="service[]" value="lawn_maint">LAWN MAINTENANCE </span></input></td>
      <td><span class="style2">
        <input type="checkbox" name="service[]" value="windows">WINDOWS</span></input></td>
    </tr>

    <tr>
      <td><span class="style2">
        <input type="checkbox" name="service[]" value="pool_maint">POOL MAINTENANCE</span></input></td>
      <td><span class="style2">
        <input type="checkbox" name="service[]" value="minor_hr">MINOR HOME REPAIR </span></input></td>
    </tr>

    <tr>
      <td><span class="style2">
        <input type="checkbox" name="service[]" value="major_hr">MAJOR HOME REPAIR </span></input></td>
      <td><span class="style2">
        <input type="checkbox" name="service[]" value="carpet_cleaning">CARPET CLEANING </span></input></td>
    </tr>

    <tr>
      <td height="23"><span class="style2">
        <input type="checkbox" name="service[]" value="plumbing">PLUMBING</span></input></td>
      <td><span class="style2">
    <input type="checkbox" name="service[]" value="electrician">ELECTRICIAN</span></input></td>
    </tr>

    <tr>
    <td height="23"><span class="style2">
      <input type="checkbox" name="service[]" value="prop_management">PROPERTY MANAGEMENT</span></input></td>
      <td><span class="style2"></span></td>
    </tr>

    <tr>
      <td height="23"><span class="style2">
        <input type="checkbox" name="service[]" value="licensed">LICENSED</span></input></td>
      <td><span class="style2">
    <input type="checkbox" name="service[]" value="bonded">BONDED</span></input></td>

    </tr>

I should add I'm brand new to PHP/MySQL programming. I have little to no experience...this is my first project. Any help will be valued, and someday I will return the favor to a newbie.


Reply With Quote