...

View Full Version : looping problem



Gez
05-18-2008, 01:48 PM
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



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==0 ){
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;
}
}

Gez
05-18-2008, 02:25 PM
Don't worry guys, i found my problem, one variable had a capital in.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum