2016-03-06 33 views
1

嗨,我有查詢問題,其中吸取自由的地方,並採取座位,然後檢查在循環PHP我寫忙碌地爲禁用複選框SQL,查詢到電影院的地方

我的數據庫瑪 enter image description here

我嘗試:

foreach ($FreePlaces as $item) { 

foreach ($busyPlaces as $items) { 


    if ($item->id_place == $items->id_place) { 
     echo Html::checkboxList('items', null, [$items->id_place => $items->number_place], ['class' => 'checkbox-inline no_indent', 'id' => 'idd']); 
    } 
    else 
    echo Html::checkboxList('items', null, [$item->id_place => $item->number_place], ['class' => 'checkbox-inline no_indent', 'id' => 'idd']); 
} 

}

,但它不工作...看圖片 enter image description here

如何標記爲禁用的繁忙地點?

$freePlace= place::find() 
     ->Where(['id_room' => seanse::find()->select('id_room')-> 
     Where(['id_seans' => $id])])->all(); 

    $busyplace=place::find()->where(['in', 'id_place', Reservation::find()->select('id_place') 
     ->where(['id_seans' => $id])]) 
     ->andWhere(['id_room' => seanse::find()->select('id_room')-> 
     Where(['id_seans' => $id])])->all(); 

解決方案

jQuery的

$("input[name='items[]']:checked").prop("disabled", true); 

PHP

$selectedArray = []; 
foreach ($zajeteKrzesla as $items) { 
    $selectedArray[] = $items->id_place; 
} 



    foreach ($WolneKrzesla as $item):?> 


     echo Html::checkboxList('items', $selectedArray, [$item->id_place => $item->number_place], ['class' => 'checkbox-inline no_indent', 'id' => 'idd']); 


    <?php endforeach; 
+0

你有問題要問? –

回答

1

如果你想標記busyPlace的選擇時,你可以更改您的代碼本(你需要適當填充$selectedArray變量):

foreach ($FreePlaces as $item) { 

foreach ($busyPlaces as $items) { 

    // $selectedArray - selection of the check boxes. 
    // This can be either a string for single selection or 
    // an array for multiple selections. 
    if ($item->id_place == $items->id_place) { 
     echo Html::checkboxList('items', $selectedArray, [$items->id_place => $items->number_place], ['class' => 'checkbox-inline no_indent', 'id' => 'idd']); 
    } 
    else 
    echo Html::checkboxList('items', null, [$item->id_place => $item->number_place], ['class' => 'checkbox-inline no_indent', 'id' => 'idd']); 
} 
} 
+0

我想禁用標記busyPlace。我更新我的問題。 [我的查詢到數據庫] – Demolog

+0

好吧,我使用SelectedArray,然後使用Jquery來禁用選定的複選框!它工作。 Thaks! – Demolog

+0

我很高興你解決了你的問題 –