php - Saving values from checkboxes in my db -


i trying store values checkboxes inside database. far, able store last checkbox choice. afterwards, tried following someone's example, got confused. how ensure data being stored inside database?

in table, column want contain information named "categories". rest, below (2 of them only)

<tr>     <td><input type="hidden" name="categories" value="categories">categories</td>                 <td>             <div class="checkbox";>                 <label class="checkbox_label">                     <input name="cats" value="accessoires" type="checkbox" class="checkbox1"/>                     accessoires                 </label>             </div>              <div class="checkbox";>                 <label class="checkbox_label">                     <input name="cats" value="mobilier de bureau " type="checkbox" class="checkbox1"/>                     mobilier de bureau                  </label>             </div>     </td> </tr> 

this code tried following:

$box=$_post['box']; $ledlamps = $_post['ledlamps'];  $str = $ledlamps . ": " . implode(", ", $box); 

and ended this:

$cats = $_post['cats']; $categories=$_post['categories'];  $str = $categories . ": " . implode(", ", $cats); 

i not have sufficient privileges add comment previous answer attempt @erman belegu saying right, cats[] should trick. here code.

the html

<tr>     <td><input type="hidden" name="categories" value="categories">categories</td>                 <td>             <div class="checkbox";>                 <label class="checkbox_label">                     <input name="cats[]" value="accessoires" type="checkbox"                        class="checkbox1"/>                     accessoires                 </label>             </div>              <div class="checkbox";>                 <label class="checkbox_label">                     <input name="cats[]" value="mobilier de bureau "                          type="checkbox" class="checkbox1"/>                     mobilier de bureau                  </label>             </div>     </td> </tr>  <input type="submit" name="submit" value="submit"/> 

the thing added submit button in php when submit clicked, here same php code.

<?php  $cats = array();      if(isset($_post['submit']))     {         if(isset($_post['cats']))         {             $cats = $_post['cats'];         }         $categories= $_post['categories'];          $str = $categories . ": " . implode(", ", $cats);         echo $str;     }  ?> 

if select , click echo see categories: , whatever selected.

hope helps or perhaps did not problem in first place.

thanks.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -