Hi there,
I wonder if anyone can help me - I've been stuck on this little problem for days! I'm making a hotel search site, and at the bottom of this page:
http://www.hotelheaven.co.uk/showhotels.php?Town=London
I am trying to insert a 'Next' button. I have everything working apart from that I have 3 different Next buttons - one for England, one for Wales and one for Scotland. These are saved, respectively, in the England folder, the Wales folder and the Scotland folder. I am therefore trying to call up these different folders in the <img src> url but i'm not having much luck.
Is there anybody out there who could tell me what's wrong with the following code??!!
<?php
//Displays all the hotels within the chosen area
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Hotel Heaven</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<?php
switch ($Region)
{
case "Scotland" :
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"/stylesheetscotland.css\">";
break;
case "Wales" :
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"/stylesheetwales.css\">";
break;
default :
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"/stylesheetengland.css\">";
break;
}
?>
</head>
<body leftmargin="0" rightmargin="0" topmargin="0" bottommargin="0" marginwidth="0" marginheight="0">
<?php
switch ($Region)
{
case "Scotland" :
include ("headerscotland.php");
break;
case "Wales" :
include ("headerwales.php");
break;
default :
include ("header.php");
break;
}
include ("misc.php");
$connection = mysql_connect($host,$user,$password)
or die ("Couldn't connect to server");
$db = mysql_select_db($database,$connection)
or die ("Couldn't select database");
class Pager
{
function getPagerData($numHits, $limit, $page)
{
$numHits = (int) $numHits;
$limit = max((int) $limit, 1);
$page = (int) $page;
$numPages = ceil($numHits / $limit);
$page = max($page, 1);
$page = min($page, $numPages);
$offset = ($page - 1) * $limit;
$ret = new stdClass;
$ret->offset = $offset;
$ret->limit = $limit;
$ret->numPages = $numPages;
$ret->page = $page;
return $ret;
}
}
// get the pager input values
$page = $_GET['page'];
$limit = 10;
$result = mysql_query("SELECT count(*) FROM hotel WHERE County='$County' or Town='".$_GET['Town']."'");
$total = mysql_result($result, 0, 0);
// work out the pager values
$pager = Pager::getPagerData($total, $limit, $page);
$offset = $pager->offset;
$limit = $pager->limit;
$page = $pager->page;
// CREATE A START VARIABLE FOR USE WITH YOUR LIMIT LATER ON
$start = ($page-1) * $limit;
// THE STARTING NUMBER IS 0, SO I ADDED 1
$starting_no = $start + 1;
if ($total - $start < $limit) {
$end_count = $total;
} elseif ($total - $start >= $limit) {
$end_count = $start + $limit;
}
//Select all hotels from the chosen area
$query = "SELECT EstablishmentName,RoomsFrom,NumBedrooms,EstablishmentType,Address1,Address2,Town,County,LongDescriptionEnglish,Hotel_Id,Region,AARating,RACRating FROM hotel WHERE County='$County' or Town='".$_GET['Town']."' LIMIT $offset, $limit";
$result = mysql_query($query)
or die ("Couldn't execute query");
?>
<table width="775" border="0" align="center" cellpadding="0" cellspacing="0" class="background">
<tr>
<td width="214" height="100%" valign="top">
<table width="214" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="214" valign="top" class="welcome">
<b>Welcome to Hotel Heaven!</b> <br><br><br><br></td>
</tr>
</table>
</td>
<td width="561">
<table width="561" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<table width="537" border="0" align="center" cellpadding="0" cellspacing="0" class="border">
<tr>
<td class="hotelsfound" colspan="2"><?php echo "Currently displaying results <b>" . $starting_no . "</b> to <b>" . $end_count . "</b> from a total of <b>" . $total . "</b> hotels."; ?></td>
</tr>
<tr>
<td class="sortby">Click here to order by cheapest</td>
<td class="sortby" align="right">Click here to order by cheapest</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="lineheight" height="12"> </td>
</tr>
<tr>
<td>
<table width="537" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="ffffff">
<?php
//Display results in a table
while ( $row = mysql_fetch_array($result,MYSQL_ASSOC) )
{
?>
<tr>
<td colspan="2">
<table width="537" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="23" class="title"><a href="http://www.hotelheaven.co.uk/hotel.php?Hotel_Id=<?php echo $row['Hotel_Id'] ?>&Region=<?php echo $row['Region'] ?>"><?php echo $row['EstablishmentName'] ?></a></td>
<td height="23" align="right" valign="middle" class="darkbackground">
<?php
for ( $i=0; $i < $row['AARating']; $i++ ) echo ("<img src=\"http://www.hotelheaven.co.uk/" . $row['Region'] . "/star.gif\">");
if ($row['AARating'] >= 1) echo ("<img src=\"http://www.hotelheaven.co.uk/" . $row['Region'] . "/AA.gif\">");
for ( $i=0; $i < $row['RACRating']; $i++ ) echo("<img src=\"http://www.hotelheaven.co.uk/" . $row['Region'] . "/star.gif\">");
if ($row['RACRating'] >= 1) echo ("<img src=\"http://www.hotelheaven.co.uk/" . $row['Region'] . "/RAC.gif\">");
?>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="contentleft" align="right">Rooms From</td>
<td class="content">£<?php echo $row['RoomsFrom'] ?></td>
</tr>
<tr class="lightbackground">
<td class="contentleft" align="right">Number of Rooms</td>
<td class="content"><?php echo $row['NumBedrooms'] ?> Bedroom <?php echo $row['EstablishmentType'] ?></td>
</tr>
<tr>
<td class="contentleft" valign="top" align="right">Address</td>
<td class="content" valign="top"><?php echo $row['Address1'] ?>, <?php echo $row['Address2'] ?>, <?php echo $row['Town'] ?>, <?php echo $row['County'] ?></td>
</tr>
<tr class="lightbackground">
<td class="contentleft" align="right" height="151"><a href="http://www.hotelheaven.co.uk/hotel.php?Hotel_Id=<?php echo $row['Hotel_Id'] ?>&Region=<?php echo $row['Region'] ?>"><img src="http://www.activehotels.com/photos/<?php echo $row['Hotel_Id'] ?>/AAB<?php echo $row['Hotel_Id'] ?>.jpg" width="180" height="135" border="0"></a></td>
<td class="content" valign="top">
<?php
$string = $row['LongDescriptionEnglish'];
$newstring_length = 400;
$string_new=(strlen($string)>$newstring_length)?substr($string,0,strpos($string," ",$newstring_length))."...":$string;
echo $string_new;
?></td>
</tr>
<tr>
<td colspan="2">
<table width="537" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="contentleft" width="494" align="right" valign="middle"><a href="http://www.hotelheaven.co.uk/hotel.php?Hotel_Id=<?php echo $row['Hotel_Id'] ?>&Region=<?php echo $row['Region'] ?>">Click here for more details or to make<br>an online reservation at <span class="details"><?php echo $row['EstablishmentName'] ?></span></a></td>
<td class="content" valign="middle" width="43"><a href="http://www.hotelheaven.co.uk/hotel.php?Hotel_Id=<?php echo $row['Hotel_Id'] ?>&Region=<?php echo $row['Region'] ?>"><img src="http://www.hotelheaven.co.uk/<?php echo $row['Region'] ?>/go.gif" border="0"></a></td>
</tr>
</table>
</td>
</tr>
<tr class="background">
<td colspan="2" height="14"> </td>
</tr>
<?php
}
?>
</table>
</td>
</tr>
<tr>
<td align="center">
<table width="537" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<?php
$data = mysql_fetch_assoc($result);
if ($page == 1) // this is the first page - there is no previous page
echo "<td> </td>";
else // not the first page, link to the previous page
echo "<td><a href=\"showhotels.php?page=" . ($page - 1) . "&Town=" . $Town . "&County=" . $County . "&Region=" . $Region . "\"><img src=\"arrowleft.gif\" border=\"0\"></a></td>";
if ($page == $pager->numPages) // this is the last page - there is no next page
echo "<td> </td>";
else // not the last page, link to the next page
echo "<td align=\"right\"><a href=\"showhotels.php?page=" . ($page + 1) . "&Town=" . $Town . "&County=" . $County . "&Region=" . $Region . "\"><img src=\"http://www.hotelheaven.co.uk/" . $data['Region'] . "/next.gif\" border=\"0\"></a>";
?>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="2">
<table width="775" border="0" align="center" cellpadding="0" cellspacing="0">
<tr class="background">
<td height="30"> </td>
</tr>
<tr>
<td bgcolor="003300"> </td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
I'd be extremely grateful if anyone can shed any light on my miserable efforts! Thank you very much!
LizzyD