corillo181 Posted June 22, 2007 Share Posted June 22, 2007 i WAS TRYING TO GET MULTIPLE CHECKBOX INTO ONE MYSQL FIELD BUT I ALWAYS GET ONLY ARRAY IN THE FIELD I HAVE IT SET UP LIKE THIS if($_post['submit']){ $allChecked=explode(',',$_post['options']); $insert=mysql_query("INSERT INTO table(checked)V('$allCheck')")or die(); } Quote Link to comment https://forums.phpfreaks.com/topic/56649-solved-checkbox/ Share on other sites More sharing options...
teng84 Posted June 22, 2007 Share Posted June 22, 2007 IN THE FIELD I HAVE IT SET UP LIKE THIS if($_post['submit']){ $allChecked=explode(',',$_post['options']); $insert=mysql_query("INSERT INTO table(checked)V('$allCheck')")or die(); } ^^^^ serious about that???? show us the real code if thats the real code that a big bug///????????? ASTIG!!! Quote Link to comment https://forums.phpfreaks.com/topic/56649-solved-checkbox/#findComment-279764 Share on other sites More sharing options...
corillo181 Posted June 22, 2007 Author Share Posted June 22, 2007 everything else works fine in the insert $year=$_POST['year']; $month=$_POST['month']; $day=$_POST['day']; $do=explode(',',$_POST['no']); $thisyear=date("Y"); $thismonth=(int)date("m"); $nextyear=$thisyear+1; $jd=cal_to_jd(CAL_GREGORIAN,$month,date(1),$year); $monthname=jdmonthname($jd,1); $array=array(1=>'January','February','March','April','May','June','July','August','September','October','November','December'); $where=$_POST['where']; $who=$_POST['who']; if(isset($_POST['Submit'])){ $insert=mysql_query("INSERT INTO tra_party(user_id,party_year,party_month,party_day,nos,place,who) VALUES('$user_id','$year','$month','$day','$do','$where','$who')")or die(mysql_error()); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/56649-solved-checkbox/#findComment-279785 Share on other sites More sharing options...
sasa Posted June 22, 2007 Share Posted June 22, 2007 can we see the form code? Quote Link to comment https://forums.phpfreaks.com/topic/56649-solved-checkbox/#findComment-279789 Share on other sites More sharing options...
corillo181 Posted June 22, 2007 Author Share Posted June 22, 2007 my form is a little complicated i don't know if you going to be able to tell , but here it is. <form action="<?=$_SERVER['PHP_SELF']?>" method="post"> <fieldset id="timeselect"> <label for="year" id="yearLabel"><span>Year</span> <select name="year" id="year" onchange="form.submit();"> <? if(empty($year) || $year=='Select'){?><option value="Select" selected="selected">Select</option> <? for($i=$thisyear;$i<=$nextyear;$i++){ ?><option value="<?=$i?>"><?=$i?></option> <? }}if($year!=''){?><option value="<?=$year?>" selected="selected"><?=$year?></option><? }?></select></label> <? if($year!=''){?> <label><span>Month</span><select name="month" id="month" onchange="form.submit();"><? if($month==''){?> <option value="0" selected="selected">Select Month</option> <? }?><? if($year==$thisyear){ $start = $thismonth; for($i = $start; $i < count($array); $i++){ ?><option value="<?=$i?>"><?=$array[$i]?></option> <? if($month==$i){?><option value="<?=$i?>" selected="selected"><?=$array[$i]?></option> <? }}}else{ $start = 1; for($i = $start; $i < count($array); $i++){?> <option value="<?=$i?>"><?=$array[$i]?></option><? if($month==$i){?> <option value="<?=$i?>" selected="selected"><?=$array[$i]?></option><? }}}?></select></label><? }?> <? if($month!=''){?> <label><span>Days</span><select name="day" id="day" onchange="form.submit();"><option value="Select" selected="selected">Select Day</option> <? $numdaysinmonth=cal_days_in_month(CAL_GREGORIAN,$month,$year); for($count=1;$count<=$numdaysinmonth;$count++){?> <option value="<?=$count?>"><?=$count?></option> <? }?></select></label><? }?> </fieldset> <? if($day!=''){?> <fieldset> <label><span>party-type:</span> <select name="partitype" id="partitype"> <option value="select" selected="selected">Select Type</option> <option value="house">House</option> <option value="club">Club</option> <option value="other">Others</option> </select> </label> <p>Check For No's : </p> <label> <input name="no[]" type="checkbox" id="beads" value="beads" /> Beads</label> <label><input name="no[]" type="checkbox" id="headgear" value="headgear" /> Head Gear</label> <label><input name="no[]" type="checkbox" id="vaggie" value="vaggie" /> Vagie clothes</label> </fieldset><? }?> <fieldset> <label><span>Where</span><input name="where" type="text" id="where" /> </label> <label><span>Who's</span> <input name="who" type="text" id="who" /> </label> </fieldset><button type="submit" name="Submit" id="Submit">Submit</button></form> Quote Link to comment https://forums.phpfreaks.com/topic/56649-solved-checkbox/#findComment-279793 Share on other sites More sharing options...
corillo181 Posted June 22, 2007 Author Share Posted June 22, 2007 no more reactions? Quote Link to comment https://forums.phpfreaks.com/topic/56649-solved-checkbox/#findComment-279822 Share on other sites More sharing options...
sasa Posted June 22, 2007 Share Posted June 22, 2007 change $do=explode(',',$_POST['no']); to $do=implode(',',$_POST['no']); Quote Link to comment https://forums.phpfreaks.com/topic/56649-solved-checkbox/#findComment-279833 Share on other sites More sharing options...
cooldude832 Posted June 22, 2007 Share Posted June 22, 2007 your issue is in design, checkboxes are boolean variables (at least by design) <input type="checkbox" name="checkbox1"/> they say if ($_POST['checkbox1']) if its check it will execute the if statement else it will not Quote Link to comment https://forums.phpfreaks.com/topic/56649-solved-checkbox/#findComment-279837 Share on other sites More sharing options...
corillo181 Posted June 22, 2007 Author Share Posted June 22, 2007 thank you.. i tried it before but it was giving my a error now i realized i had to have it inside the if statement because implode looks for the array as soon as the page is loaded if there is no statement. Quote Link to comment https://forums.phpfreaks.com/topic/56649-solved-checkbox/#findComment-279842 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.