Monday, May 3, 2010

Checkbox mutiple value Transfer in Database using PHP Code

At first Create Database then you create table something like that:

create table users(
id int(10) not null auto_increment,
checkbox varchar(60) not null,
primary key(id)
) engine=myisam;

Then using PHP coding:


$food = $_POST["food"];


$data="";
/*
foreach($food as $values)
{
$data.=$values.",";
}
*/
//new way .....

$data=implode(",", $food);

$query="insert into users values('','$data')";
$result=mysql_query($query);

Create form:


Please choose type of residence:
Steak
Pizza
Chicken