samedi 6 juin 2015

i get chechbox values but if i won`t select one of them it does not send into db although it keep a record,dose not show what should i do?

 <input type="checkbox" name="f[]"value="sport">
 <input type="checkbox" name="f[]"value="reading">
 <input type="checkbox" name="f[]"value="arguments">
 <input type="checkbox" name="f[]"value="tv">

and this is the php:

if(isset($_POST['f'])){
         if(in_array("sport",$_POST['f'])){
             $sport = $_POST['f'];
             $sport = 1;} 
         if(in_array("reading",$_POST['f'])){
             $reading = $_POST['f'];
             $reading = 1;} 
         if(in_array("arguments",$_POST['f'])){
             $argument = $_POST['f'];
             $argument = 1;} 
         if(in_array("tv",$_POST['f'])){
             $tv = $_POST['tv'];
             $tv = 1;} 
         $problem = false;

         } else{
             $e = false;
             $sport = 0;
             $reading = 0;
             $argument = 0;
             $tv = 0;
         }  

so what is wrong? what should i do?problem comes when i won`t select any of those checkboxes! plus it dose not send to mysql it set record but does not show that! even the code says that if none of them were checked get them value of 0! and it must get the 0 in mysql but it refuse to do that....




Aucun commentaire:

Enregistrer un commentaire