i have had this code for some time, it has worked perfectly displaying results, i have recently tried to add a distance calculator, but i am having some trouble incorporating it into my pages. Any help on this matter would be greatly appreciated.
<?php
mysql_connect"my details"
$limit = 16;
$query_count = "SELECT * FROM UK_Hotels where Town like 'Ashbourne'";
$result_count = mysql_query($query_count);
$totalrows = mysql_num_rows($result_count);
if(empty($page)){
$page = 1;
}
$limitvalue = $page * $limit - ($limit);
$query = "SELECT * FROM UK_Hotels where Town like 'Ashbourne'ORDER BY EstablishmentName ASC LIMIT $limitvalue, $limit";
$result = mysql_query($query) or die("Error: " . mysql_error());
if(mysql_num_rows($result) == 0){
echo("Nothing to Display!");
}
$bgcolor = "#E0E0E0"; // light gray
echo("<table width='100%'>");
while($row = mysql_fetch_array($result)){
$bgcolor = "#FFFFFF";
$Bookings_Hyperlink = $row['BookingsHyperlink'];
$RatingTypec = $row['RatingTypec'];
$Num_Bedrooms = $row['Num_Bedrooms'];
$Establishment_Type = $row['EstablishmentType'];
$Child_Rate = $row['Child_Rate'];
$American_Express = $row['AmericanExpress'];
$Diners_Card = $row['DinersCard'];
$Visa = $row['Visa'];
$Switch = $row['Switch'];
$Latitude = $row['Latitude'];
$Longitude = $row['Longitude'];
$Country = $row['Country'];
$Region = $row['Region'];
$Long_Description = $row['LongDescription'];
$AA_Rating = $row['AARating'];
$RAC_Rating = $row['RACRating'];
$Tourist_Board_Rating = $row['TouristBoardRating'];
$county_id = $row['countyid'];
$Booking_Form = $row['BookingForm'];
$Local_Tourist_Board = $row['LocalTouristBoard'];
$French_Rating = $row['French_Rating'];
$International_Rating = $row['InternationalRating'];
$Self_Accredited = $row['Self_Accredited'];
$Geo_Country = $row['GeoCountry'];
$Geo_Region = $row['GeoRegion'];
$Geo_County = $row['GeoCounty'];
$Geo_Subdivision = $row['GeoSubdivision'];
$Geo_Town = $row['GeoTown'];
$Hotel_Id = $row['HotelId'];
$Home_Hyperlink = $row['HomeHyperlink'];
$Address1 = $row['Address1'];
$Address2 = $row['Address2'];
$Post_Code = $row['PostCode'];
$Town = $row['Town'];
$County = $row['County'];
$Description = $row['Description'];
$Establishment_Name = $row['EstablishmentName'];
$Rooms_From = $row['RoomsFrom'];
$URL = $row['URL'];
function distance($lat1, $lon1, $lat2, $lon2, $unit) {
$theta = $lon1 - $lon2;
$dist = sin(deg2rad($lat1)) sin(deg2rad($lat2)) + cos(deg2rad($lat1)) cos(deg2rad($lat2)) cos(deg2rad($theta));
$dist = acos($dist);
$dist = rad2deg($dist);
$miles = $dist 60 * 1.1515;
$unit = strtoupper($unit);
if ($unit == "K") {
return ($miles 1.609344);
} else if ($unit == "N") {
return ($miles 0.8684);
} else {
return $miles;
}
}
$distlatlon = distance(52.9873, -1.8906, $Latitude, $Longitude, 'm') . ' miles';
echo("<tr bgcolor=".$bgcolor."><td width='17%' align='center' valign='middle'>");
echo ("<p>
<font face='Verdana' size='1'><img src='http://www.activehotels.com/photos/$Hotel_Id/AAB$Hotel_Id.jpg' alt='$Establishment_Name' width='100' height='75' border='1'></td>
<td width='83%' valign='left'><font face='Verdana' size='1'><a href='../hotels/$URL.htm'>$Establishment_Name</a><br>
<font face='Verdana' size='1'>$Address1 $Address2 $Town $Post_Code<br>
$Description... <a href='../hotels/$URL.htm'>More</a><br>
Click here to book the <a href='../bookingpages/$URL.htm'>$Establishment_Name</a><br>
<strong>Rooms are available from $Rooms_From GBP</strong><br>
This Hotel Is $distlatlon From Alton Towers
</p>
");
echo("</td></tr>");
}
echo("</table>");
echo("<table><font color='#000000' face='Verdana' size='1'>");
if($page != 1){
$pageprev = $page-1;
echo("<a href=\"$PHP_SELF?page=$pageprev\"> Previous 16 hotels </a> ");
}else{
echo(" First Page ");
}
$numofpages = $totalrows / $limit;
for($i = 1; $i <= $numofpages; $i++){
if($i == $page){
echo($i." ");
}else{
echo("<a href=\"$PHP_SELF?page=$i\"> $i </a> ");
}
}
if(($totalrows % $limit) != 0){
if($i == $page){
echo($i." ");
}else{
echo("<a href=\"$PHP_SELF?page=$i\"> $i </a> ");
}
}
if(($totalrows - ($limit * $page)) > 0){
$pagenext = $page+1;
echo("<a href=\"$PHP_SELF?page=$pagenext\"> Next 16 hotels </a>");
}else{
echo("Last Page ");
}
mysql_free_result($result);
echo("</table>");
?>
This code displays one result, with Fatal error: Cannot redeclare distance() above it, the longitude and latitude allready in are of alton towers, the $longitude should be of our information in the database.
Once again, Any help is GREATLY appreciated
Kind Rgards
Lee Thornton