Insert checkbox values In normalize db PHP
<p>Firstly my idea to store multiple checkboxes in my DB is below.</p>

<pre><code>if (in_array(",", $_POST['categories'])) { /* Other was selected */}
        $cat = implode(" ,", $_POST['categories']);
if (in_array(",", $_POST['subcat'])) { /* Other was selected */}
        $sub = implode(" ,", $_POST['subcat']);
if (in_array(",", $_POST['type'])) { /* Other was selected */}
        $type = implode(" ,", $_POST['type']);
if (in_array(",", $_POST['payment'])) { /* Other was selected */}
        $payment = implode(" ,", $_POST['payment']);
</code></pre>

<p>I have read some articles that this is wrong so i set up some new tables for each of the values above.($cat,$sub,$type,$payment).</p>

<p>all of them looks like this:</p>

<pre><code>   Destination_id | category_id

        444             5
        444             22
        444             30
</code></pre>

<p>With that said I would like some help on how to make my loop that would store all the values in the various tables. like above. so I might use them in later searches.</p>

<p>EDIT: this is my insert btw and it will have other values.</p>

<pre><code>$sql = "INSERT INTO tbl_locations SET

                name='".$_POST['name']."', 
                alias='".$_POST['alias']."',
                category_id='$cat',
                subcategory_id='$sub',
                tourism_type_id='$type',
                lgu_id='$payment',
                latitude='".$_POST['latbox']."', 
                longitude='".$_POST['lngbox']."'
            ";
</code></pre>

<p>EDIT: Sorry my bad is this ok.</p>

<pre><code>            &lt;input type="checkbox" name="categories[]" value=2 id=Food and Drink&gt;&lt;label for=Food and Drink class="fil_lab"&gt;Food and Drink&lt;/label&gt;
        &lt;input type="checkbox" name="categories[]" value=7 id=Nightlife and Entertainment&gt;&lt;label for=Nightlife and Entertainment class="fil_lab"&gt;Nightlife and Entertainment&lt;/label&gt;
        &lt;input type="checkbox" name="categories[]" value=1 id=Place to Stay&gt;&lt;label for=Place to Stay class="fil_lab"&gt;Place to Stay&lt;/label&gt;
        &lt;input type="checkbox" name="categories[]" value=4 id=Point of Interest&gt;&lt;label for=Point of Interest class="fil_lab"&gt;Point of Interest&lt;/label&gt;
        &lt;input type="checkbox" name="categories[]" value=6 id=Shopping&gt;&lt;label for=Shopping class="fil_lab"&gt;Shopping&lt;/label&gt;&lt;br&gt;&lt;br&gt;
        &lt;input type="checkbox" name="categories[]" value=5 id=Spa and Wellness&gt;&lt;label for=Spa and Wellness class="fil_lab"&gt;Spa and Wellness&lt;/label&gt;
        &lt;input type="checkbox" name="categories[]" value=3 id=Tourist Attraction&gt;&lt;label for=Tourist Attraction class="fil_lab"&gt;Tourist Attraction&lt;/label&gt;       
</code></pre>
