I have an multiple divs which are formed dynamically. Inside each div i have a list of checkboxes and a single dropdown. The list of checkboxes contain the hotel name and category and a single dropdown containing the hotel rating. The user can select the checkboxes or select an option from the dropdown. By default is the checkbox. If the user does not select the checkbox then the value of the dropdown should be taken into consideration for the particular city.
This is the code that i have tried in the controller but i am not getting the desired result. Can someone help me with this pls?
if (isset($_POST['city'])) {
$city = $_POST['city'];
if (is_array($city)) {
foreach ($this->input->post('city') as $city) {
$cityid[] = $city;
// $category.= $this->input->post('category_' . $city) . ",";
// $categorycity.= $city . ",";
// $prefsightseeing.= $this->input->post('prefsight_' . $city) . ",";
// $prefsightseeingcity.= $city . ",";
//$hotel = $_POST['hotel'];
if (isset($_POST['hotel'])) {
$hotel = $_POST['hotel'];
// if (is_array($hotel) && in_array($city, $hotel)) {
foreach ($this->input->post('hotel') as $city_id) {
$arr = explode('_', $city_id);
if (in_array($arr[1], $cityid)) {
$hotelcityid.= $arr[1] . ',';
$hotelid.= $arr[2] . ',';
}
// }
}
}
else{ if (isset($_POST['category'])) {
$category = $_POST['category'];
foreach ($this->input->post('category') as $category) {
$arr = explode('_', $category);
// echo $arr[1];
// print_r($cityid);
if (in_array($arr[1], $cityid)) {
$hotelcategory.= $arr[0] . ',';
$categorycity.= $city . ',';
}
}
}
}
// $hotelid.= $arr[2] . ',';
}
$categorycity = rtrim($categorycity, ',');
$category = rtrim($hotelcategory, ',');
$category= implode(',', array_keys(array_flip(explode(',', $category))));
$categorycity= implode(',', array_keys(array_flip(explode(',', $categorycity))));
// $prefsightseeing = rtrim($prefsightseeing, ',');
// $prefsightseeingcity = rtrim($prefsightseeingcity, ',');
}
}
if ($category != "") {
$arrData['HotelInfoByCategory'] = $this->previewpackage_model->get_hotel_info_by_category($category, $categorycity);
}
Thanks,