Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-18-2008, 01:48 PM   PM User | #1
Gez
New Coder

 
Join Date: May 2008
Posts: 32
Thanks: 4
Thanked 0 Times in 0 Posts
Gez is an unknown quantity at this point
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 02:05 PM..
Gez is offline   Reply With Quote
Old 05-18-2008, 02:25 PM   PM User | #2
Gez
New Coder

 
Join Date: May 2008
Posts: 32
Thanks: 4
Thanked 0 Times in 0 Posts
Gez is an unknown quantity at this point
Don't worry guys, i found my problem, one variable had a capital in.
Gez is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:00 AM.


Advertisement
Log in to turn off these ads.