HElP insert multiple checkbox data into MySQL

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dynastym3
Forum Newbie
Posts: 13
Joined: Sun Apr 05, 2009 2:12 am

HElP insert multiple checkbox data into MySQL

Post 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());

}
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: HElP insert multiple checkbox data into MySQL

Post 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.
dynastym3
Forum Newbie
Posts: 13
Joined: Sun Apr 05, 2009 2:12 am

Re: HElP insert multiple checkbox data into MySQL

Post 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.
dynastym3
Forum Newbie
Posts: 13
Joined: Sun Apr 05, 2009 2:12 am

Re: HElP insert multiple checkbox data into MySQL

Post by dynastym3 »

any sugestions??? HELP!!!
Post Reply