Home » questions » how to insert a multiple value into database but not a single column?
how to insert a multiple value into database but not a single column?
I have a table in my database (call roomtype) with the rows roomtype_id(Primary Key) and room_type.
I have another table (call bookdetail) with the rows book_id, guest_ic and roomtype_id.I have a simple form that allow user check the checkbox which room they want to stay.
Standard Twin
Standard Queen\
Family
after they check, will post it to another page.Did anybody know how to insert the value to the field roomtype_id in table bookdetail?Eg:
book_id -----guest_ic--------------- roomtype_id
2 --------840116 -------------- 1
2 ---------840116 ------------- 1
2 ------------840116 -------------- 2
but my problem is the roomtype_id only store a last value:2 but the value 1 never store?Can anybody help?Pls
if(!isset($_POST['room_type_id']))
{
//array is empty
$_POST['room_type_id'] = array();
echo "None selected.";
}
else
{
//must do this for checkboxes (passing multiple values)
foreach ($_POST['room_type_id'] as $items)
{
echo $items;
}
}
when i echo to see the result, i get :112 and then value in field roomtype_id (table bookdetail) will only store the value "2".Where is another two value "1" store?Can anybody help me solve this problem?I'm new in php.Pls help.... i have try to search this problem since last week, but untill now i cant find a solution.Pls help.... thank you :(

Answers
AnalProgrammer
On 2006-08-15 06:08:29
thomasalanshearer
On 2006-08-15 02:21:34