gpt4 book ai didi

php - 如果特定酒店(度假村)的客房类型不止一种,如何在下拉菜单中填充度假村(酒店)的客房类型?

转载 作者:行者123 更新时间:2023-11-29 16:26:15 27 4
gpt4 key购买 nike

我正在开发一个在线旅行预订系统。事实上,我购买了一个在线预订系统,并且正在根据我的需要对其进行修改。这里的问题是针对特定度假村或酒店的空房情况查询表。我想用该特定酒店的房间类型填充下拉菜单,但如果酒店有不止一种房间类型,我无法填充下拉菜单

这是要求填充下拉菜单的特定代码

 $result_room = $db->query("SELECT * FROM pm_room WHERE checked = 1 AND id_hotel = '.$hotel_id.' AND lang = ".LANG_ID); 

房间表是“pm_room”,该表中有一个酒店 ID 列,即“id_hotel”

我修改的文件是search-min.php

下面是search-min.php中的代码

<?php
debug_backtrace() || die ("Direct access not permitted");

$max_adults_search = 5;
$max_children_search = 10;

if(!isset($_SESSION['destination_id'])) $_SESSION['destination_id'] = 1;
if(!isset($destination_name)) $destination_name = "";

if(!isset($_SESSION['num_adults']))
$_SESSION['num_adults'] = (isset($_SESSION['book']['adults'])) ? $_SESSION['book']['adults'] : 1;
if(!isset($_SESSION['num_children']))
$_SESSION['num_children'] = (isset($_SESSION['book']['children'])) ? $_SESSION['book']['children'] : 0;

$from_date = (isset($_SESSION['from_date'])) ? $_SESSION['from_date'] : "";
$to_date = (isset($_SESSION['to_date'])) ? $_SESSION['to_date'] : ""; ?>

<form action="<?php echo DOCBASE.$sys_pages['booking']['alias']; ?>" method="post" class="">
<?php
if(isset($hotel_id)){ ?>
<input type="hidden" name="hotel_id" value="<?php echo $hotel_id; ?>">
<?php
} ?>



<div class="form-group">
<label class="sr-only" for="from"></label>
<div class="input-group">
<div class="input-group-addon"><i class="fa fa-calendar"></i> <?php echo $texts['CHECK_IN']; ?></div>
<input type="text" class="form-control" id="from_picker" name="from_date" value="<?php echo $from_date; ?>">
</div>
</div>
<div class="form-group">
<div class="input-group">
<div class="input-group-addon"><i class="fa fa-calendar"></i> <?php echo $texts['CHECK_OUT']; ?></div>
<input type="text" class="form-control" id="to_picker" name="to_date" value="<?php echo $to_date; ?>">
</div>
</div>





<div class="form-group">
<div class="input-group">
<div class="input-group-addon"><i class="fa fa-tags"></i> <?php echo $texts['ROOM']; ?></div>
<select class="form-control" name="room_id">
<?php


$result_room = $db->query("SELECT * FROM pm_room WHERE checked = 1 AND id_hotel = '.$hotel_id.' AND lang = ".LANG_ID);


if($result_room !== false){
foreach($result_room as $i => $row){ ?>
<option value="<?php echo $row['id']; ?>"><?php echo $row['title']; ?></option>
<?php
}
} ?>
</select>
</div>
</div>




<div class="form-group">
<div class="input-group">
<div class="input-group-addon"><i class="fa fa-male"></i> <?php echo $texts['ADULTS']; ?></div>
<select name="num_adults" class="selectpicker form-control">
<?php
for($i = 1; $i <= $max_adults_search; $i++){
$select = ($_SESSION['num_adults'] == $i) ? " selected=\"selected\"" : "";
echo "<option value=\"".$i."\"".$select.">".$i."</option>";
} ?>
</select>
</div>
</div>
<div class="form-group">
<div class="input-group">
<div class="input-group-addon"><i class="fa fa-male"></i> <?php echo $texts['CHILDREN']; ?></div>
<select name="num_children" class="selectpicker form-control">
<?php
for($i = 0; $i <= $max_children_search; $i++){
$select = ($_SESSION['num_children'] == $i) ? " selected=\"selected\"" : "";
echo "<option value=\"".$i."\"".$select.">".$i."</option>";
} ?>
</select>
</div>
</div>



<div class="form-group">
<button class="btn btn-primary" type="submit" name="check_availabilities"><i class="fa fa-search"></i> <?php echo $texts['CHECK']; ?></button>
</div>
</form>

如果酒店只有一种房型,则使用此代码会填充房间的下拉菜单:例如: https://www.thesandsmaldives.com/resorts/niyama

但是,如果酒店有不止一种房型,则不会填充房型下拉列表。例如: https://www.thesandsmaldives.com/resorts/oblu-by-atmosphere-at-helengeli

我在这里做错了什么?

最佳答案

我在购买它的原始编码员的帮助下找到了它,这是一个语法错误。我使用的是单引号和双引号。使用其中之一,但不能同时使用;)我刚刚发现这是我的错,

所有房间类型都存储在 pm_room 表中,但该表中有一个酒店 id 列,用于确定房间类型适用于哪家酒店正确的代码是

$result_room = $db->query("SELECT * FROM pm_room WHERE checked = 1 AND id_hotel = ".$hotel_id." AND lang = ".LANG_ID);

关于php - 如果特定酒店(度假村)的客房类型不止一种,如何在下拉菜单中填充度假村(酒店)的客房类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54215019/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com