Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: looping problem

  1. #1
    Gez
    Gez is offline
    New Coder
    Join Date
    May 2008
    Posts
    32
    Thanks
    4
    Thanked 0 Times in 0 Posts

    looping problem

    ok so heres the, i have a form where the user can select which room they would like (single or double) and depending on what answer they choose the specific form will come up with the specific price for that type of room. but the problem is that never mind which i choose i always get the price for the single room, any ideas?
    Gez

    PHP Code:
    Function hotelform(){
        
        echo
    "
        <form action='"
    .$_SERVER['PHP_SELF']."' method='GET'>
            <table align='center' width='400' border='0'>
                <tr>
                    <td align='right'>Resort:</td>
                    <td><input type='text' name='destination'></td>
                  </tr>
                  <tr>
                    <td align='right'>Check In Date:</td>
                    <td><input type='text' name='checkin'>(YYYY-MM-DD)</td>
                  </tr>
                  <tr>
                    <td align='right'>Check Out Date:</td>
                    <td><input type='text' name='checkout'>(YYYY-MM-DD)</td>
                  </tr>
                  <tr>
                    <td align='right'>Single Room: <input type='radio' name='roomtype' value='single'></td>
                    <td>Double Room: <input type='radio' name='roomtype' value='double'></td>
                  </tr>
                <tr>
                    <td colspan='2' align='center'><input type='submit' value='Take me there!'></td>
                </tr>
            </table>
        </form>"
    ;
        }
        
        Function 
    showhotels(){
        
        
    $table_hotel="hotel";
        
        
    $ResortName=$_REQUEST['destination'];
        
    $Roomtype=$_REQUEST['roomtype'];
        
        
    $roomvalue=0;
        
    // check the room type
        
    if ( $roomtype == 'single' ) {
        
    $roomvalue 0;
        } else if ( 
    $roomtype == 'double' )
        {
        
    $roomvalue 1;
        } else {
        echo 
    "Please select a room type!";
        }
        
         
    // Set query    
        
    $queryhotel="SELECT * FROM $table_hotel
                        WHERE Resort = '"
    .$ResortName."'";
    // Do query    
        
    $hotelresult mysql_query($queryhotel) or die (mysql_error());
        
        echo 
    "<table align='center' width='800' border='1'>
              <tr>
                <td align='center'><b>Resort:</b> </td>
                <td align='center'><b>Website:</b></td>
                <td align='center'><b>Star Rating:</b></td>
                <td align='center'><b>Score:</b></td>
                <td align='center'><b>Cost per Night:</b></td>
                <td align='center'></td>
              </tr>"
    ;
        
        
        
    // Show results for the specific room

        
    if ( $roomvalue==){
            while (
    $row mysql_fetch_array$hotelresult )){
            echo 
    "<tr>";
                echo 
    "    <td align='center'>".$row['Resort']."</td>";
                echo 
    "    <td align='center'><a href='".$row['WebAddress']."'>".$row['WebAddress']."</a></td>";
                echo 
    "    <td align='center'>".$row['Star']."</td>";
                echo 
    "    <td align='center'>".$row['Score']."</td>";
                echo 
    "    <td align='center'>".$row['SingleRoom']."&euro;</td>";
                echo 
    "    <td align='center'></td>";
                  echo 
    " </tr>";
            }
            echo 
    "</table><br/><br>";
            echo 
    $roomvalue;
        } else {
            while (
    $row mysql_fetch_array$hotelresult )){
            echo 
    "<tr>";
                echo 
    "    <td align='center'>".$row['Resort']."</td>";
                echo 
    "    <td align='center'><a href='".$row['WebAddress']."'>".$row['WebAddress']."</a></td>";
                echo 
    "    <td align='center'>".$row['Star']."</td>";
                echo 
    "    <td align='center'>".$row['Score']."</td>";
                echo 
    "    <td align='center'>".$row['DoubleRoom']."&euro;</td>";
                echo 
    "    <td align='center'></td>";
                  echo 
    " </tr>";
            }
            echo 
    "</table><br/><br>";
            echo 
    $roomvalue;
            }
        } 
    Last edited by Gez; 05-18-2008 at 03:05 PM.

  • #2
    Gez
    Gez is offline
    New Coder
    Join Date
    May 2008
    Posts
    32
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Don't worry guys, i found my problem, one variable had a capital in.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •