我无法将从$ _GET []收到的值分配给变量

I am trying to pick the id using the $_GET[] and assign it to a variable however it does not work. when i try to echo $_GET[] directly it works fine the ID is displayed on the page, however when i assign it to a variable and try to echo it, it wont work. for example this wont work:

$sel_hotel = $_GET[];
echo $sel_hotel; 

The code looks fine there is no any problem with it but it just don't pass that value to the variable i believe there may be something wrong with my php.ini file but i am not sure. i am using PHP Version 5.4.3. Please Help . Thank you very Much

<?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>

Every time you set variables from the $_GET, you erase them after...

Try:

<?php 
  $sel_hotel = "";
  $sel_room  = "";

  if(isset($_GET['hotl']))
  {
    $sel_hotel = $_GET['hotl']; 
    echo $sel_hotel;
  }
  elseif(isset($_GET['room']))
  {
    $sel_room = $_GET['room'];
    echo $sel_room;
  }

  echo $sel_hotel;
?>

You reset your variables after retrieving the $_GET value in both cases - they're empty because YOU are emptying them.

The problem is that once you set the variables, you clear them to be an empty string. The second line of this is the problem:

$sel_hotel = $_GET['hotl']; 
$sel_hotel ="";

What logic flow were you trying to achieve with this? I'd recommend either just deleting those lines or moving them to the top of the script, if you need to make sure they're empty when it runs.