Page 1 of 1

HElP insert multiple checkbox data into MySQL

Posted: Mon Apr 06, 2009 12:44 pm
by dynastym3
How do I insert multiple checkbox data into MySQL, I tried to put it in the database but it says array or it will only store on piece of data instead of multiple data
Heres my code:

html:

<input type="checkbox" name="tran[]" value="Mon">
Monday
<input type="checkbox"name="tran[]" value="Tue">
Tuesday
<input type="checkbox" name="tran[]" value="Wed">
Wednesday
<input type="checkbox" name="tran[]" value="Thur">
Thursday
<input type="checkbox"name="tran[]" value="Fri">
Friday

php:
$tran = $_POST[tran];

if($_POST['Submit'] == 'Submit')
{
mysql_query("INSERT INTO $usertable(`days`,`time`,`trans`,`subject`,`grade`,`skill`,`oskill`,`status`) VALUES ('$day','$time','$tran','$subj', '$grade', '$skills','$oskill','1')")or die(mysql_error());

}

Re: HElP insert multiple checkbox data into MySQL

Posted: Mon Apr 06, 2009 1:28 pm
by requinix
dynastym3 wrote:I tried to put it in the database but it says array
Probably because $_POST["tran"] is an array.
dynastym3 wrote:or it will only store on piece of data instead of multiple data
So fix your code. I don't know what you're trying to do with it so I can't offer much more help.

Re: HElP insert multiple checkbox data into MySQL

Posted: Mon Apr 06, 2009 3:17 pm
by dynastym3
basically if I click on Mon & Tues I want it to show Mon Tues in the data base in. But it will only show one of days that I click on in the database.

Re: HElP insert multiple checkbox data into MySQL

Posted: Tue Apr 07, 2009 4:38 pm
by dynastym3
any sugestions??? HELP!!!