Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8218141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:41:19+00:00 2026-06-07T12:41:19+00:00

I am trying to pick the id using the $_GET[] and assign it to

  • 0

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>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T12:41:20+00:00Added an answer on June 7, 2026 at 12:41 pm

    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;
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to explode an string using javascript to pick searchterms, whitespace-separated. However
I'm trying to run an Icecast stream using a simple Python script to pick
I am trying to get jquery to pick up variable that I am defining
I'm trying to query a DBF file using System.Data.Odbc.OdbcConnection. It works correctly when the
I'm using ReSharper 6 and I'm trying to get it to pick up my
I'm trying to pick up Lua programming but I'm stuck on something that's probably
I am trying to use 'get_posts' to pick up posts that are in two
OK, this is minefield, but trying to understand why one would pick .NET (or
Trying to comply with StackOverflow's suggestion of asking a question, not creating a discussion,
Trying to get parameters from a PUT request using HttpServlet#doPut: public void doPut(HttpServletRequest request,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.