我在这里面临一个大问题。我的酒店公司从一家南非公司购买了一个用PHP制作的Booking系统,他们的合同到期了,现在他们要收取很多钱来更新合同和添加我们需要的新功能,所以现在所有的负担都留给了我……等等,所以我有这张桌子:
,我想在每个房间添加多种类型的房间。例如:1号房,类型:简易房,两张床,三张床 表代码:
<div class="table-responsive">
<table id="datatable-fixed-header" class="table datatable-show-all table-striped table-bordered">
<thead>
<tr>
<th>Nº</th>
<th>Floar</th>
<th>Room No.</th>
<th>Price per Night ( In <?php echo $currency_symbol; ?> )</th>
<th>Price per Week ( In <?php echo $currency_symbol; ?> )</th>
<th>Type</th>
<th>State</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
if (count($room_details) > 0) {
$s_no = 1;
foreach ($room_details as $room) {
echo'<tr>
<td>' . $s_no . '</td>
<td>' . $room["property_name"] . '</th>
<td>' . $room["room_number"] . '</th>
<td class="text-right format_currency_td">' . $room["room_standard_night_rate"] . '</td>
<td class="text-right format_currency_td">' . $room["room_standard_weekly_rate"] . '</td>
<td>' . $room["room_type_name"] . '</td>';
if ($room["room_status"] == "AVAILABLE")
echo'<td><span class="label label-success">' . $room["room_status"] . '</span></td>';
else if ($room["room_status"] == "OCUPADO")
echo'<td><span class="label label-info">' . $room["room_status"] . '</span></td>';
else if ($room["room_status"] == "MANUNTEINCE")
echo'<td><span class="label label-warning">' . $room["room_status"] . '</span></th>';
else if ($room["room_status"] == "OUT OF SERVICE")
echo'<td><span class="label label-danger">' . $room["room_status"] . '</span></td>';
echo'<td>';
if ($room["room_status"] != "OUT OF SERVICE")
echo'<div class="th_options_kit">
<span class="th_options btn bg-teal-400 btn-icon btn-rounded btn_edit_room" data-room="' . $room["room_id"] . '" data-popup="tooltip" title="Edit Room" data-placement="left"><i class="icon-pen"></i></span>
<span class="btn bg-danger-400 btn-icon btn-rounded btn_delete_room" data-room="' . $room["room_id"] . '" data-popup="tooltip" title="Delete Room" data-placement="left"><i class="icon-bin"></i></span>
</div>';
else if ($room["room_status"] == "OUT OF SERVICE")
echo'<div class="th_options_kit">
<span class="th_options btn bg-teal-400 btn-icon btn-rounded btn_edit_room" data-room="' . $room["room_id"] . '" data-popup="tooltip" title="Room is out of service" data-placement="left"><i class="icon-pen"></i></span>
</div>';
echo'</td>
</tr>';
$s_no++;
}
}else {
}
?>
</tbody>
</table>
</div>
Php代码:
public function getRoom($where = FALSE) {
$this->db->select('room.`room_id`, '
. 'room.`property_id`, '
. 'room.`room_number`, '
. 'room.`room_type`,'
. 'room.`room_standard_night_rate`,'
. 'room.`room_standard_weekly_rate`,'
. 'room.`room_status`,'
. 'prop.`property_name`,'
. 'room_type.`room_type_name`'
);
$this->db->from('hm_room room');
$this->db->join('hm_room_type room_type', 'room.`room_type` IN (room_type.`room_type_id`)');
$this->db->join('hm_property prop', 'room.`property_id` IN (prop.`property_id`)');
if ($where !== FALSE) {
foreach ($where as $whr) {
$this->db->where_in($whr["column_name"], $whr["data"]);
}
}
$this->db->order_by("prop.`property_name`", "ASC");
$this->db->order_by("room.`room_number`", "ASC");
$query = $this->db->get();
return $query->result_array();
}
请帮助我解决这个问题。
答案 0 :(得分:1)
希望我能理解您的问题,您的表格目前仅显示“房间类型”,例如简单。您现在要显示的是“简单两张床”而不是“简单”吗?
然后您需要做的是连接您的字段。我似乎看不到“两张床”的数据库字段,但是假设它是“ room_beds”,那么您需要执行以下操作:
第一步是将数据库字段名称添加到查询中,假设数据库中的字段名称称为“ room_beds”
$this->db->select('room.`room_id`, '
. 'room.`property_id`, '
. 'room.`room_number`, '
. 'room.`room_type`,'
. 'room.`room_standard_night_rate`,'
. 'room.`room_standard_weekly_rate`,'
. 'room.`room_status`,'
. 'prop.`property_name`,'
. 'prop.`room_beds`,' -- Add the here
. 'room_type.`room_type_name`');
最后,您需要将room_beds字段连接到您已经拥有的room_type_name,如下所示:
<td>'. $room["room_type_name"] .' ,'. $room["room_beds"] .'</td>';