我正在尝试使用 选择 id 并将其$_GET[]
分配给一个变量,但是它不起作用。当我尝试$_GET[]
直接回显它工作正常时,ID 显示在页面上,但是当我将它分配给一个变量并尝试回显它时,它不会工作。例如这不起作用:
$sel_hotel = $_GET[];
echo $sel_hotel;
代码看起来很好,没有任何问题,但它只是不将该值传递给变量我相信我的 php.ini 文件可能有问题,但我不确定。我正在使用 PHP 版本 5.4.3。请帮忙 。非常感谢你
<?php
if(isset($_GET['hotl'])){
$sel_hotel = $_GET['hotl'];
$sel_hotel ="";
echo $sel_hotel;
}elseif(isset($_GET['room'])){
$sel_room = $_GET['room'];
$sel_room ="";
echo $sel_room;
}else{
$sel_hotel ="";
$sel_room ="";
}
echo $sel_hotel;
?>
<?php require_once("includes/header.php");?>
<?php require_once("includes/function.php");?>
<?php //require_once("TheDatabase.php")?>
<?php $connection = mysql_connect("localhost","root","root");
if(!$connection){
die("Database Connection Failed :". mysql_error());
}else{
$db_select = mysql_select_db("travelnstay", $connection);
if(!$db_select){
die("Database Selection Failed:". mysql_error());
}
}
?>
<div class="Calign">
<div class="mar">
<div>
<p>Menu</p>
<?php
$hotel_set = select_all_hotels();
while($hotel = mysql_fetch_array($hotel_set)){
echo "<p class=\"mar\"><a href=\"admincontent.php?hotl=" .
urlencode($hotel["hotel_id"]).
"\">{$hotel["hotel_name"]}</a></span></p>";
$room_set = room_by_id($hotel["hotel_id"]);
echo "<ul>";
while($room= mysql_fetch_array($room_set)){
echo "<li><a href=\"admincontent.php?room=". urlencode($room["room_id"]).
"\">{$room["room_type"]}</a></li>";
echo"</ul>";
}
}
echo "<p> Its is suppose to be here".$sel_hotel."</p>";
echo "<p>". $sel_room. "</p>";
?>
</div><!--end of the mar-->
</div><!--end of the Calign-->
</body>
</html>