Page 1 of 1

Behaviour of assigning mysql_fetch_array to another array

Posted: Thu Sep 25, 2003 3:18 am
by Nunners
I have the following line in my code:

Code: Select all

$eastingї$row_num]=$accommodationї"EASTING"];
echo("Easting Test: ".$accommodationї"EASTING"]." and ".$eastingї$row_num]);
$accommodation is a mysql_fetch_array, with EASTING being a field within it.
$row_num is increasing each time the mysql_fetch_array passes through, using ++;

The output I get is as follows:
Easting Test: 369234 and 3
Now am I completely loosing it, or should the two numbers not be the same?
It would seem when assigning the value to the array $easting, it only takes the first digit. Is this a fault, a problem with my code, or just one of those things?!?

Many thanks
Nunners

Posted: Thu Sep 25, 2003 3:42 am
by twigletmac
Does this test code work as expected:

Code: Select all

<?php
$row_num = 1;
$accommodation['EASTING'] = 369234;
$easting[$row_num] = $accommodation["EASTING"];
echo("Easting Test: ".$accommodation["EASTING"]." and ".$easting[$row_num]); 
?>
It gave the expected result when I ran it.

Mac

Posted: Thu Sep 25, 2003 3:51 am
by Nunners
Easting Test: 369234 and 3
Is the result I got again!

I seem to remember reading somewhere about the behaviour of calling an array straight after you have declared a value, but I can't remember what it was.

Just to explain a little further. There are a series of 3 mysql_fetch_arrays, which list 3 different types of people. They are then displayed on a map, as image dots, with links to them. I obviously need to pick up their location (using easting and northing), and the easiest way I think to do this, is create a standard set of arrays that exists through the 3 mysql_fetch_arrays.

If anyone is interested, the website is http://www.visitheartofengland.com and it's under the WhereToStay Section. We are adding a new type of membership, which means people appear with different templates.

If anyone wants to see the code, I'm happy to put it here, however, it is rather long!

Thanks twigletmac!

Nunners

Posted: Thu Sep 25, 2003 4:06 am
by twigletmac
I think that you've got $easting declared as a string somewhere in your code, in a separate test script (with nothing else in it) try the first bit of code (which should produce the correct result) and then try this code

Code: Select all

<?php
$row_num = 1;
$easting = 'test';
$accommodation['EASTING'] = 369234;
$easting[$row_num] = $accommodation["EASTING"];
echo("Easting Test: ".$accommodation["EASTING"]." and ".$easting[$row_num]); 
?>
in which I was able to replicate your problem.

Mac

Posted: Thu Sep 25, 2003 4:26 am
by Nunners
Same result I'm afraid.

Could it be the php setup?

Posted: Thu Sep 25, 2003 4:31 am
by Nunners

Code: Select all

<?php
include("../page_head.php");
$section="Where to Stay";
if (isset($_GET["accomm_type"])) {
	$accomm_type=$_GET["accomm_type"];
} else {
	$accomm_type="ALL";
}
include("../global/map_search.php");
#SQL Statements:
$class_sql="";
$standards="trips_resource.ALL_STANDARDS!='' AND trips_resource.ALL_STANDARDS!=':'";
$order_sql="ORDER BY CLASS_CODE ASC, QA_RATING DESC, RAND()";
$grid_sql=" ((trips_resource.easting>'".$easting_min."' AND trips_resource.easting<'".$easting_max."' AND trips_resource.northing>'".$northing_min."' AND trips_resource.northing<'".$northing_max."') OR (trips_resource.easting>('".$easting_min."'/10) AND trips_resource.easting<('".$easting_max."'/10) AND trips_resource.northing>('".$northing_min."'/10) AND trips_resource.northing<('".$northing_max."'/10))) ";
if (isset($_GET["accomm_type"])) {
	if ($_GET["accomm_type"]=="ALL") {
		$class_sql=" ";
	} elseif ($_GET["accomm_type"]=="Self-Catered") {
		$class_sql=" AND trips_accommodation.class_code IN ('NC','NCS','NSK','NS','NSS','NSA','NSF','NSG') ";
	} elseif ($_GET["accomm_type"]=="Serviced") {
		$class_sql=" AND trips_accommodation.class_code IN ('SI','SHM','SH','SHT','SG','SB','SHK','SHC','SF','SHA') ";
	} elseif ($_GET["accomm_type"]=="Group") {
		$class_sql=" AND trips_accommodation.class_code IN ('OYC','OY') ";
	} elseif ($_GET["accomm_type"]=="Camping") {
		$class_sql=" AND trips_accommodation.class_code IN ('NP','NPF','NPS') ";
	} 
}
$list_sql_gold="select trips_resource.NORTHING, trips_resource.EASTING, trips_accommodation.QA_AWARD AS Award, trips_accommodation.QA_RATING AS ETC, trips_accommodation.NIS_NR_AA_RATING AS AA, trips_accommodation.NIS_NR_RAC_RATING AS RAC, trips_resource.ALL_STANDARDS, trips_resource.resource_id, trips_resource.resource_name1, trips_resource.resource_name2, trips_resource.place_no, trips_accommodation.class_code from trips_resource, trips_accommodation where ".$standards." AND ".$members_list." AND trips_resource.RESOURCE_ID IN (".Sql_Members("2").") AND trips_resource.RESOURCE_ID=trips_accommodation.RESOURCE_ID AND ".$grid_sql." ".$class_sql." ".$order_sql;
$list_sql_silver="select trips_resource.NORTHING, trips_resource.EASTING, trips_accommodation.QA_AWARD AS Award, trips_accommodation.QA_RATING AS ETC, trips_accommodation.NIS_NR_AA_RATING AS AA, trips_accommodation.NIS_NR_RAC_RATING AS RAC, trips_resource.ALL_STANDARDS, trips_resource.resource_id, trips_resource.resource_name1, trips_resource.resource_name2, trips_resource.place_no, trips_accommodation.class_code from trips_resource, trips_accommodation where ".$standards." AND ".$members_list." AND trips_resource.RESOURCE_ID IN (".Sql_Members("1").") AND trips_resource.RESOURCE_ID=trips_accommodation.RESOURCE_ID AND ".$grid_sql." ".$class_sql." ".$order_sql;
$list_sql_members="select trips_resource.NORTHING, trips_resource.EASTING, trips_accommodation.QA_AWARD AS Award, trips_accommodation.QA_RATING AS ETC, trips_accommodation.NIS_NR_AA_RATING AS AA, trips_accommodation.NIS_NR_RAC_RATING AS RAC, trips_resource.ALL_STANDARDS, trips_resource.resource_id, trips_resource.resource_name1, trips_resource.resource_name2, trips_resource.place_no, trips_accommodation.class_code from trips_resource, trips_accommodation where ".$standards." AND ".$members_list." AND trips_resource.RESOURCE_ID NOT IN (".Sql_Members("1").") AND trips_resource.RESOURCE_ID NOT IN (".Sql_Members("2").") AND trips_resource.RESOURCE_ID=trips_accommodation.RESOURCE_ID AND ".$grid_sql." ".$class_sql." ".$order_sql;
$list_sql_nonmembers="select trips_accommodation.QA_AWARD AS Award, trips_resource.ALL_STANDARDS, trips_resource.BKG_TEL_FULL, trips_resource.CON_TEL_FULL, trips_resource.TEL1_FULL, trips_resource.resource_id, trips_resource.resource_name1, trips_resource.resource_name2, trips_resource.place_no, trips_accommodation.class_code from trips_resource, trips_accommodation where ".$standards." AND ".$non_members_list." AND trips_resource.RESOURCE_ID=trips_accommodation.RESOURCE_ID AND ".$grid_sql." ".$class_sql." ".$order_sql;
#$mapping_sql="select trips_resource.resource_id, trips_resource.resource_name1, trips_resource.resource_name2, trips_resource.con_place_no, trips_accommodation.class_code from trips_resource, trips_accommodation where ".$standards." AND ".$members_list." AND trips_resource.RESOURCE_ID=trips_accommodation.RESOURCE_ID AND ".$grid_sql." ".$class_sql;
?><table border="0" cellpadding="0" cellspacing="0">
	<tr>
		<td valign=top rowspan="2">
<?php

Function Accessibility_Rating ($resource_id) {
	include("../db.php");
	$string="";
	$sql="select * from Accessibility_ratings where RESOURCE_ID='".$resource_id."'";
	$result=mysql_query($sql,$connect);
	while ($list=mysql_fetch_array($result)) {
		if ($list["M_Rating"]!="0") {
			$string.="M".$list["M_Rating"]." , ";
		}	
		if ($list["V_Rating"]!="0") {
			$string.="V".$list["V_Rating"]." , ";
		}	
		if ($list["H_Rating"]!="0") {
			$string.="H".$list["H_Rating"]." , ";
		}	
	}
	return $string;
}

Function Written_Rating ($rating_list) {
#	echo("<b>".$rating_list."</b><br>");
	$string="";
	if ($rating_list==":" OR $rating_list=="") {
		$string="n/a";
	} else {
		$rating_array=explode(',',trim($rating_list));
		foreach ($rating_array as $rating_strings) {
			$rating_string=trim($rating_strings);
			if ($rating_string=="ETC" OR $rating_string=="AA" OR $rating_string=="RAC") {
				$string=$string;
			} else {
				list($org,$full_rating)=explode(":",$rating_string);
				if (trim($full_rating)=="APPLIED" OR trim($full_rating)=="Applied") {
					$string=$string."tbc";
				} elseif (trim($full_rating)=="GA" OR trim($full_rating)=="4TH" OR trim($full_rating)=="TA") {
					$string=$string.$org;
				} else {
					list($rating,$award)=explode(" ",trim($full_rating));
					#list($number,$letter)=split("",trim($rating));
					#SWITCH ($letter) {
					#	Case "D":
					#		$string=$string.$number." Diamonds";
					#		break;
					#	Case "D":
					#		$string=$string.$number." Stars";
					#		break;
					#	default:
					#		$string=$string.$number." ".$letter;
					#}
						$string=$string.$rating;
				}
			} 
		}
	}
	return $string;
}

Function Show_Stars ($code) {
	$string="";
	SWITCH ($code) {
		CASE "1S":
			$string.="<img src="/images/general/star.gif" alt="Star">";
			break;
		CASE "2S":
			$string.="<img src="/images/general/star.gif" alt="Star"><img src="/images/general/star.gif" alt="Star">";
			break;
		CASE "3S":
			$string.="<img src="/images/general/star.gif" alt="Star"><img src="/images/general/star.gif" alt="Star"><img src="/images/general/star.gif" alt="Star">";
			break;
		CASE "4S":
			$string.="<img src="/images/general/star.gif" alt="Star"><img src="/images/general/star.gif" alt="Star"><img src="/images/general/star.gif" alt="Star"><img src="/images/general/star.gif" alt="Star">";
			break;
		CASE "5S":
			$string.="<img src="/images/general/star.gif" alt="Star"><img src="/images/general/star.gif" alt="Star"><img src="/images/general/star.gif" alt="Star"><img src="/images/general/star.gif" alt="Star"><img src="/images/general/star.gif" alt="Star">";
			break;
		CASE "4-5S":
			$string.="<img src="/images/general/star.gif" alt="Star"><img src="/images/general/star.gif" alt="Star"><img src="/images/general/star.gif" alt="Star"><img src="/images/general/star.gif" alt="Star"> to <img src="/images/general/star.gif" alt="Star"><img src="/images/general/star.gif" alt="Star"><img src="/images/general/star.gif" alt="Star"><img src="/images/general/star.gif" alt="Star"><img src="/images/general/star.gif" alt="Star">";
			break;
		CASE "3-4S":
			$string.="<img src="/images/general/star.gif" alt="Star"><img src="/images/general/star.gif" alt="Star"><img src="/images/general/star.gif" alt="Star"> to <img src="/images/general/star.gif" alt="Star"><img src="/images/general/star.gif" alt="Star"><img src="/images/general/star.gif" alt="Star"><img src="/images/general/star.gif" alt="Star">";
			break;
		CASE "2-3S":
			$string.="<img src="/images/general/star.gif" alt="Star"><img src="/images/general/star.gif" alt="Star"> to <img src="/images/general/star.gif" alt="Star"><img src="/images/general/star.gif" alt="Star"><img src="/images/general/star.gif" alt="Star">";
			break;
		CASE "1-2S":
			$string.="<img src="/images/general/star.gif" alt="Star"> to <img src="/images/general/star.gif" alt="Star"><img src="/images/general/star.gif" alt="Star">";
			break;
		CASE "1-3S":
			$string.="<img src="/images/general/star.gif" alt="Star"> to <img src="/images/general/star.gif" alt="Star"><img src="/images/general/star.gif" alt="Star"><img src="/images/general/star.gif" alt="Star">";
			break;
		CASE "1D":
			$string.="<img src="/images/general/diamond.gif" alt="Diamond">";
			break;
		CASE "2D":
			$string.="<img src="/images/general/diamond.gif" alt="Diamond"><img src="/images/general/diamond.gif" alt="Diamond">";
			break;
		CASE "3D":
			$string.="<img src="/images/general/diamond.gif" alt="Diamond"><img src="/images/general/diamond.gif" alt="Diamond"><img src="/images/general/diamond.gif" alt="Diamond">";
			break;
		CASE "4D":
			$string.="<img src="/images/general/diamond.gif" alt="Diamond"><img src="/images/general/diamond.gif" alt="Diamond"><img src="/images/general/diamond.gif" alt="Diamond"><img src="/images/general/diamond.gif" alt="Diamond">";
			break;
		CASE "5D":
			$string.="<img src="/images/general/diamond.gif" alt="Diamond"><img src="/images/general/diamond.gif" alt="Diamond"><img src="/images/general/diamond.gif" alt="Diamond"><img src="/images/general/diamond.gif" alt="Diamond"><img src="/images/general/diamond.gif" alt="Diamond">";
			break;
		CASE "APPLI":
			$string.="Applied";
			break;
		default:
			$string.=$ETC;
	}
	return $string;
}

Function Logo_Rating ($ETC,$AA,$RAC,$AWARD) {
#$string="ETC: ".$ETC." / AA ".$AA." / RAC ".$RAC."<br>";
$string="";

if ($ETC!="") {
	$string.=Show_Stars($ETC);
} else {
	if ($AA!="") {
		$string.="AA: ".Show_Stars($AA);
	}
	if ($RAC!="") {
		$string.="RAC: ".Show_Stars($RAC);
	}
}
if ($AWARD!="") {
	SWITCH ($AWARD) {
		CASE "Gold":
			$string.="<br><font color="#ffcc00">Gold Award</font>";
			break;
		CASE "GOLD":
			$string.="<br><font color="#ffcc00">Gold Award</font>";
			break;
		CASE "Silver":
			$string.="<br><font color="gray">Silver Award</font>";
			break;
		CASE "SILVER":
			$string.="<br><font color="gray">Silver Award</font>";
			break;
	}
}
return $string;
}

Function etc_rating_image ($rating,$sector) {
if ($rating=="") {
$string="";
} else {
$string="<img src="/images/ratings/etc/rose.gif" alt="English Quality Assurance Scheme"><br><img src="/images/ratings/etc/".$sector.$rating.".gif" alt="".$rating."">";
return $string;
}
}
Function aa_rating_image ($rating) {
if ($rating=="") {
$string="";
} else {
$string="<img src="/images/ratings/aa/aa".$rating.".gif" alt="".$rating."">";
}
return $string;
}
Function rac_rating_image ($rating) {
if ($rating=="") {
$string="";
} else {
$string="<img src="/images/ratings/rac/rac".$rating.".gif" alt="".$rating."">";
}
return $string;
}

?>
<table width="144" border="0" cellpadding="0" cellspacing="0" background="/side_bar/side_background.gif" bgcolor="#FFFFFF">
		<tr>
			<td background="/top_bar_images/top_background.gif"><img src="/side_bar/side_top.gif" width="144" height="20"></td>
		</tr>
		<tr>
			<td background="/side_bar/pink_back.gif"><img src="/side_bar/pink_shadow.gif" width="144" height="3"></td>
		</tr>
		<tr>
			<td background="/side_bar/pink_back.gif" align=center class=mainbig>Where to Stay:</td>
		</tr>
		<tr>
			<td background="/side_bar/pink_back.gif"><img src="/side_bar/pink_to-_red.gif" width="144" height="4"></td>
		</tr>
		<tr>
			<td align=center class=white width="144"><br>
				<!--<a href="#HolidayParks" class="white">Caravan & Camping</a><br>
				<a href="#SelfCatering" class="white">Self Catering</a><br>
				<a href="#BandB" class="white">Bed & Breakfast</a><br>
				<a href="#Farm" class="white">Farm Accommodation</a><br>
				<a href="#Serviced" class="white">Hotels/Guesthouses</a><br>
				<a href="#Group" class="white">Group Accommodation</a><br>
				<a href="#Other" class="white">Other Accommodation</a><br>-->
			</td>
		</tr>
		<tr>
			<td><img src="" height="40" width="1"></td>
		</tr>
		<tr>
			<td><img src="/side_bar/insde_14.gif"></td>
		</tr>
		<tr>
			<td bgcolor="#FFFFFF" align="center">	<?php
#							include("../global/advertising.php");
						?>
			</td>
		</td>
	</table>
	
		</td>
		<td colspan="2" class="sectionheader" align="center">
			<br><p class="sectionheader" align="center">Where to Stay - Search</p><br>
		</td>
	</tr>
	<tr>
		<td width="372" valign="top"><br>
	<table width="100%">
	<?php
	$list_result=mysql_query($list_sql_members,$connect);
	$list_result_gold=mysql_query($list_sql_gold,$connect);
	$list_result_silver=mysql_query($list_sql_silver,$connect);
	$row_num=0;
	if (mysql_num_rows($list_result)=="0" AND mysql_num_rows($list_result_silver)=="0" AND mysql_num_rows($list_result_gold)=="0") {
	?>
		<tr>
			<td align="center" class="Main">No Members to display<br><br><hr></td>
		</tr>
	<?php
	} else {
	#Gold Members:
	while ($accommodation=mysql_fetch_array($list_result_gold)) {
		$row_num++;
		$resource_id[$row_num]=$accommodation["resource_id"];
		$icon[$row_num]=Class_Colour($accommodation["class_code"]);
		$name[$row_num]=stripslashes($accommodation["resource_name1"])." ".stripslashes($accommodation["resource_name2"]);
		$northing[$row_num]=$accommodation["NORTHING"];
		$easting[$row_num]=$accommodation["EASTING"];
	?>
		<tr>
			<td>
				<table width="100%">
					<tr>
						<td valign="top">
							<p class="Main"><big><big><b><?php echo(stripslashes($accommodation["resource_name1"])." ".stripslashes($accommodation["resource_name2"])); ?></b></big></big>							<?php
								echo(Logo_Rating($accommodation["ETC"],$accommodation["AA"],$accommodation["RAC"],$accommodation["Award"]));
							?><br><br>
							<big><?php echo(Place($accommodation["place_no"])); ?></big><br><br>
							<font color="<?php echo(Class_Colour($accommodation["class_code"])); ?>"><big><?php echo(Class_Code($accommodation["class_code"])); ?></big></font><br>
							<br>
							<a href="accommodation.php?RESOURCE_ID=<?php echo($accommodation["resource_id"]); ?>"><big>More info</big></a></p>
						</td>
						<td align="right" valign="top">
							<?php
							echo(Display_Logo($accommodation["resource_id"]));
							?>
						</td>
					</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td colspan="1"><hr></td>
		</tr>
	<?php
	}
	#Silver Members:
	echo("<br>");
	$row_num = 1; 
	$easting = 'test';
	$accommodation['EASTING'] = 369234; 
	$easting[$row_num] = $accommodation["EASTING"]; 
	echo("Easting Test: ".$accommodation["EASTING"]." and ".$easting[$row_num]); 
 	echo("<br>");
	while ($accommodation=mysql_fetch_array($list_result_silver)) {
		$row_num++;
		echo("Row: ".$row_num."<br>");
		$resource_id[$row_num]=$accommodation["resource_id"];
		$icon[$row_num]=Class_Colour($accommodation["class_code"]);
		$name[$row_num]=stripslashes($accommodation["resource_name1"])." ".stripslashes($accommodation["resource_name2"]);
		$northing[$row_num]=$accommodation["NORTHING"];
		$easting[$row_num]=$accommodation["EASTING"];
		echo($easting[$row_num]);
	?>
		<tr>
			<td>
				<table width="100%">
					<tr>
						<td valign="top">
							<p class="Main"><big><big><b><?php echo($row_num." - ".stripslashes($accommodation["resource_name1"])." ".stripslashes($accommodation["resource_name2"])); ?></b></big></big>							<?php
								echo(Logo_Rating($accommodation["ETC"],$accommodation["AA"],$accommodation["RAC"],$accommodation["Award"]));
							?><br><br>
							<big><?php echo(Place($accommodation["place_no"])); ?></big><br><br>
							<font color="<?php echo(Class_Colour($accommodation["class_code"])); ?>"><big><?php echo(Class_Code($accommodation["class_code"])); ?></big></font><br>
							<br>
							<a href="accommodation.php?RESOURCE_ID=<?php echo($accommodation["resource_id"]); ?>"><big>More info</big></a></p>
						</td>
						<td align="right" valign="top">
							<?php
							echo(Display_Logo($accommodation["resource_id"]));
							?>
						</td>
					</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td colspan="1"><hr></td>
		</tr>
	<?php
	}
	#Standard Members:
	while ($accommodation=mysql_fetch_array($list_result)) {
		$row_num++;
		$resource_id[$row_num]=$accommodation["resource_id"];
		$icon[$row_num]=Class_Colour($accommodation["class_code"]);
		$name[$row_num]=stripslashes($accommodation["resource_name1"])." ".stripslashes($accommodation["resource_name2"]);
		$northing[$row_num]=$accommodation["NORTHING"];
		$easting[$row_num]=$accommodation["EASTING"];
	?>
		<tr>
			<td>
				<table width="100%">
					<tr>
						<td class="MainBig"><?php echo(stripslashes($accommodation["resource_name1"])."<br>".stripslashes($accommodation["resource_name2"])); ?></td>
						<td align="right" class="Main">
							<font color="<?php echo(Class_Colour($accommodation["class_code"])); ?>"><?php echo(Class_Code($accommodation["class_code"])); ?></font><br>
							<?php
								echo(Logo_Rating($accommodation["ETC"],$accommodation["AA"],$accommodation["RAC"],$accommodation["Award"]));
							?>
						</td>
					</tr>
					<tr>
						<td class="Main"><?php echo(Place($accommodation["place_no"])); ?></td>
						<td align="right"><a href="accommodation.php?RESOURCE_ID=<?php echo($accommodation["resource_id"]); ?>">More info</a></td>
					</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td colspan="1"><hr></td>
		</tr>
	<?php
	}
	}
	?>
		<tr>
			<td colspan="1" align="center" class="MainBig"><b>Other Accommodation Available:</b></td>
		</tr>
	<?php
	$class_code="";
	$list_result=mysql_query($list_sql_nonmembers,$connect);
	if (mysql_num_rows($list_result)=="0") {
	?>
		<tr>
			<td align="center" class="Main">None to display<br><br><hr></td>
		</tr>
	<?php
	} else {
	while ($accommodation=mysql_fetch_array($list_result)) {
	?>
		<tr>
			<td class="Main" align="center">
				<b><?php 
					if (Class_Code($accommodation["class_code"])!=$class_code) {
						echo(Class_Code($accommodation["class_code"]));
						$class_code=Class_Code($accommodation["class_code"]);
					}
				?></b>
				<table width="100%">
					<tr>
						<td class="Main"><?php echo(stripslashes($accommodation["resource_name1"])." ".stripslashes($accommodation["resource_name2"])); ?>, <?php echo(Place($accommodation["place_no"])); ?></td>
						<td class="Main" align="right">	
							Rating: <?php
								echo(Written_Rating($accommodation["ALL_STANDARDS"]));
								if ($accommodation["Award"]!="") {
									SWITCH ($accommodation["Award"]) {
									CASE "Gold":
										echo("<br>Gold Award");
										break;
									CASE "GOLD":
										echo("<br>Gold Award");
										break;
									CASE "Silver":
										echo("<br>Silver Award");
										break;
									CASE "SILVER":
										echo("<br>Silver Award");
										break;
									}
								}

								?>
						</td>
					</tr>
					<tr>
						<td class="Main"><?php 
							if ($accommodation["TEL1_FULL"]!="") {
								echo($accommodation["TEL1_FULL"]);
							} elseif ($accommodation["BKG_TEL_FULL"]!="") {
								echo($accommodation["BKG_TEL_FULL"]);
							} elseif ($accommodation["CON_TEL_FULL"]!="") {
								echo($accommodation["CON_TEL_FULL"]);
							}
							?></td>
					</tr>
				</table>
			</td>
		</tr>
	<?php
	}
	}
	?>
</table>
		</td>
		<td align="left" valign="top" width="460"><br>
<?php 
if (mysql_num_rows($map_result)==0) { echo("error"); } else {
if ($map_scale>1) { 
?>
<script language="JavaScript" type="text/javascript">
<!--
function located() {
accommChoice = MapSearch.accomm_type.selectedIndex
searchChoice = MapSearch.search_type.selectedIndex
location.href="/" + MapSearch.search_type.options[searchChoice].value + "/search.php?search_type=clicked&click_x=" + event.offsetX + "&click_y=" + event.offsetY + "&pixels=300&scale=<?php echo($map_scale); ?>&easting_min=<?php echo($easting_min); ?>&easting_max=<?php echo($easting_max); ?>&northing_min=<?php echo($northing_min); ?>&northing_max=<?php echo($northing_max); ?>&accomm_type=" + MapSearch.accomm_type.options[accommChoice].value;
return true;
   }
function change_search() {
accommChoice = MapSearch.accomm_type.selectedIndex
searchChoice = MapSearch.search_type.selectedIndex
location.href="/" + MapSearch.search_type.options[searchChoice].value + "/search.php?<?php echo($_SERVER["QUERY_STRING"]); ?>&accomm_type=" + MapSearch.accomm_type.options[accommChoice].value;
return true;
}
function accomm_search() {
<?php
if (isset($_GET["accomm_type"])) {
	list($query_string,$blank)=explode('accomm_type',$_SERVER["QUERY_STRING"]);
} else {
	$query_string=$_SERVER["QUERY_STRING"];
}
?>
accommChoice = MapSearch.accomm_type.selectedIndex
location.href="search.php?<?php echo($query_string); ?>&accomm_type=" + MapSearch.accomm_type.options[accommChoice].value;
return true;
}
//-->
</script>
<?php } ?>
	<form name="MapSearch" method="GET">
		<table width="340" border="0" cellspacing="0" cellpadding="0" align="center">
			<tr>
				<td width="20">&nbsp;</td>
				<td width="300" align="center">
					<p align="center">
          Things to see and do in this area: <select name="search_type" size="1" class="drop" onchange="javascript:change_search()">
            <option value="explore">Explore the Region</option>
            <!--<option value="whatson">What's On</option>-->
            <option value="wheretostay" selected>Where to Stay</option>
            <option value="placestovisit">Places to Visit</option>
            <!--<option value="waterways">Waterways</option>-->
          </select><br>
					Accommodation Type:
					<select name="accomm_type" size="1" class="drop" onchange="javascript:accomm_search()">
						<option value="ALL">Refine Search:</option>
						<option value="ALL" <?php if (isset($_GET["accomm_type"])) { if ($_GET["accomm_type"]=="ALL") { echo("selected"); } } ?>>ALL</option>
						<option value="Serviced" <?php if (isset($_GET["accomm_type"])) { if ($_GET["accomm_type"]=="Serviced") { echo("selected"); } } ?>>Hotels, Bed & Breakfasts, Guesthouses</option>
						<option value="Self-Catered" <?php if (isset($_GET["accomm_type"])) { if ($_GET["accomm_type"]=="Self-Catered") { echo("selected"); } } ?>>Self Catering</option>
						<option value="Camping" <?php if (isset($_GET["accomm_type"])) { if ($_GET["accomm_type"]=="Camping") { echo("selected"); } } ?>>Camping & Caravanning</option>
						<option value="Group" <?php if (isset($_GET["accomm_type"])) { if ($_GET["accomm_type"]=="Group") { echo("selected"); } } ?>>Group</option>
					</select>
					</p>
				</td>
			  <td width="20">&nbsp;</td>
			</tr>
			<tr>
				<td width="20">&nbsp;</td>
				<td width="300" align="center" height="20">
					<?php #UP
						$easting_calc=$easting;
						$northing_calc=$northing+($map_scale*10000);
						if (MapCheck($easting_calc,$northing_calc,$map_scale)) {
							echo("<a href="/wheretostay/search.php?search_type=move&scale=".$map_scale."&easting=".$easting_calc."&northing=".$northing_calc."&accomm_type=".$accomm_type."">");
					?>
					<img border="0" src="/images/maps/up.gif" alt="Up">
					<?php echo("</a>"); 
						}
					?>
				</td>
			  <td width="20">&nbsp;</td>
			</tr>
			<tr>
				<td valign="middle" align="right" width="20">
					<?php #LEFT
						$easting_calc=$easting-($map_scale*10000);
						$northing_calc=$northing;
						if (MapCheck($easting_calc,$northing_calc,$map_scale)) {
							echo("<a href="/wheretostay/search.php?search_type=move&scale=".$map_scale."&easting=".$easting_calc."&northing=".$northing_calc."&accomm_type=".$accomm_type."">");
					?>
					<img border="0" src="/images/maps/left.gif" alt="Left">
					<?php echo("</a>"); 
						}
					?>
				</td>
				<td width="300" align="center">
					<div id="parent" style="position: relative; width: 300px; height: 300px">
          	<img src="<?php echo($map_filename); ?>" <?php if ($map_scale>10) { ?> onclick="javascript:located()" <?php } ?>> 
						<?php
							if ($row_num<80) {
#								FOR ($count=1;$count<=10;$count++) {
#									if ($northing[$count]<1000000) {
#										$multiple=10;
# 								} else {
#										$multiple=1;
#									}
#									$north=(($northing[$count]*$multiple)-$northing_min)*3/(100*$map_scale);
#									$east=(($easting[$count]*$multiple)-$easting_min)*3/(100*$map_scale);
#									echo("<div id='icon_".$resource_id[$count]."' style='position: absolute; bottom: $north; left: $east'>\n");
#									echo("	<a href="accommodation.php?RESOURCE_ID=".$resource_id[$count].""><img src='/images/maps/".$icon[$count]."_icon.gif' name='icon_img_".$resource_id[$count]."' border='0' alt='".$name[$count]."'></a>\n");
#									echo("</div>\n");
#								}

/**								while ($accommodation_row=mysql_fetch_array($accommodation_result)) {
									if ($accommodation_row["northing"]<1000000) {
										$multiple=10;
									} else {
										$multiple=1;
									}
									$north=(($accommodation_row["northing"]*$multiple)-$northing_min)*3/(100*$map_scale);
									$east=(($accommodation_row["easting"]*$multiple)-$easting_min)*3/(100*$map_scale);
									echo("<div id='icon_".$accommodation_row["resource_id"]."' style='position: absolute; bottom: $north; left: $east'>\n");
									echo("	<a href="accommodation.php?RESOURCE_ID=".$accommodation_row["resource_id"].""><img src='/images/maps/".Class_Colour($accommodation_row["class_code"])."_icon.gif' name='icon_img_".$accommodation_row["resource_id"]."' border='0' alt='".stripslashes($accommodation_row["resource_name1"])." ".stripslashes($accommodation_row["resource_name2"])."'></a>\n");
									echo("</div>\n");
								}**/
							} else {
								echo("<div id='TooMany' style='position: absolute; bottom: 150; left: 60'>\n");
								echo("<font color="red">Too many to display on map</font>");
								echo("</div>\n");
							}
						?>
					</div>
				</td>
			  <td valign="middle" width="20" align="left">
					<?php #RIGHT
						$easting_calc=$easting+($map_scale*10000);
						$northing_calc=$northing;
						if (MapCheck($easting_calc,$northing_calc,$map_scale)) {
							echo("<a href="/wheretostay/search.php?search_type=move&scale=".$map_scale."&easting=".$easting_calc."&northing=".$northing_calc."&accomm_type=".$accomm_type."">");
					?>
					<img border="0" src="/images/maps/right.gif" alt="Right">
					<?php echo("</a>"); 
						}
					?>
				</td>
			</tr>
			<tr>
				<td width="20">&nbsp;</td>
				<td width="440" align="center" height="20">
					<?php #DOWN
						$easting_calc=$easting;
						$northing_calc=$northing-($map_scale*10000);
						if (MapCheck($easting_calc,$northing_calc,$map_scale)) {
							echo("<a href="/wheretostay/search.php?search_type=move&scale=".$map_scale."&easting=".$easting_calc."&northing=".$northing_calc."&accomm_type=".$accomm_type."">");
					?>
					<img border="0" src="/images/maps/down.gif" alt="Down">
					<?php echo("</a>"); 
						}
					?>
				</td>
			  <td width="20">&nbsp;</td>
			</tr>
			<tr>
				<td colspan="3" align="center">
					<p align="center">Zoom: <?php
						if ($map_scale!=100) { echo("<a href="/wheretostay/search.php?search_type=move&scale=100&easting=".$easting."&northing=".$northing."&accomm_type=".$accomm_type."">100</a> "); } else { echo("100 "); }
						if ($map_scale!=50) { echo("<a href="/wheretostay/search.php?search_type=move&scale=50&easting=".$easting."&northing=".$northing."&accomm_type=".$accomm_type."">50</a> "); } else { echo("50 "); }
						if ($map_scale!=10) { echo("<a href="/wheretostay/search.php?search_type=move&scale=10&easting=".$easting."&northing=".$northing."&accomm_type=".$accomm_type."">10</a> "); } else { echo("10 "); }
					?> </p>
				</td>
			</tr>
		</table>
	</form>
<?php
}

?>
		</td>
	</tr>
</table>
<?php
include("../page_foot.php");
?>

Posted: Thu Sep 25, 2003 4:35 am
by Nunners
Solved it!

Thanks TwigletMac.

As you can see, I've posted the code - not sure why!?!?!

In ../global/map_search.php it uses easting and northing as variables. So I've changed the variable names lower down, and bingo!!!

Many thanks
Nunners