php - SQL,查询电影院

标签 php mysql sql yii2

<分区>

您好,我在查询时遇到问题,该查询会绘制空闲位置并占用座位,然后在循环中检查 php 我将繁忙的地方写为禁用复选框

我的数据库Shema 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();

解决方案

查询

 $( "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;

最佳答案

如果你想将 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']);
}
}

关于php - SQL,查询电影院,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35828813/

相关文章:

php - Laravel Eloquent 多重belongsTo播种

php - 在 MongoDB 和 php 中更新许多文档

java - DB2 错误 SQLCODE=-103,SQLSTATE=42604

php - 获取 GROUP_CONCAT 值作为单独的值

mysql - 我正在尝试创建一个数据库,但我一直遇到同样的错误,根据我和我的同学的说法,代码很好

php - 存储在 MySQL 中并在 HTML 表中显示可变数量的行

php - json_encode 中小 float 的表示

javascript - 如何使用ajax将文件从html页面发送到php,然后将其存储在mysql数据库中BLOB类型的列中?

sql - 如何编写此 MySQL 查询?

mysql - 如何将 mysql 结果以 XML 格式导出到 OUTFILE?