Hi Hope some one can help. I use the array() function to display towns. I am writting the code so I can just add the data into the array, then use explode to get the individual elements. I have created the set-up no problem but when I do not use a str_replace the search only picks up the first part of the town name. this then works fine but I want the form to display Abbots Leigh and not Abbots_Leigh with the underscore. I have tried many methods like including the stripslashes() function as such
<td width=""><img src="images/freelisting_arrow2.gif" alt=""> <a href=resulttown.php?town=<? echo $townsArray['0']; ?> class="menu"><font size="1" face="Verdana"> <? echo stripslashes($townsArray[0]); ?> ( <? echo $num; ?> )</a></font></td>
but this does not work. Any ideas, here is a cut down version of my code.
<?
$towns = "Abbots_Leigh,Almondsbury,Alveston,Backwell,Barrow Gurney,Bedminster,Berkeley,Bishopston";
$townsArray= explode(",", $towns);
$townsArray = array_diff($townsArray, array(""));
$townsArray = str_replace(' ', '_', $townsArray);
//print_r($townsArray);
include("dbinfo.inc.php");
mysql_connect($host,$username,$password);
mysql_select_db($database) or die(mysql_error());
$query ="SELECT * FROM tenant_data WHERE town='$townsArray[0]'";
$query1="SELECT * FROM tenant_data WHERE town='$townsArray[1]'";
$query2="SELECT * FROM tenant_data WHERE town='$townsArray[2]'";
$query3="SELECT * FROM tenant_data WHERE town='$townsArray[3]'";
$query4="SELECT * FROM tenant_data WHERE town='$townsArray[4]'";
$query5="SELECT * FROM tenant_data WHERE town='$townsArray[5]'";
$query6="SELECT * FROM tenant_data WHERE town='$townsArray[6]'";
$query7="SELECT * FROM tenant_data WHERE town='$townsArray[7]'";
$result=mysql_query($query);
$result1=mysql_query($query1);
$result2=mysql_query($query2);
$result3=mysql_query($query3);
$result4=mysql_query($query4);
$result5=mysql_query($query5);
$result6=mysql_query($query6);
$result7=mysql_query($query7);
$num=mysql_num_rows($result);
$num1=mysql_num_rows($result1);
$num2=mysql_num_rows($result2);
$num3=mysql_num_rows($result3);
$num4=mysql_num_rows($result4);
$num5=mysql_num_rows($result5);
$num6=mysql_num_rows($result6);
$num7=mysql_num_rows($result7);
?>
<table>
<tr><font size="2" face="Verdana"><h4><b>Browse by Town</b></h4></font>
<table style="border-style:solid; border-width:1px; border-color:#000000;" width="800" bgcolor="#FFFFFF" cellpadding="0" cellspacing="0" align="center">
<td width=""><img src="images/freelisting_arrow2.gif" alt=""> <a href=resulttown.php?town=<? echo $townsArray['0']; ?> class="menu"><font size="1" face="Verdana"> <? echo $townsArray['0']; ?> ( <? echo $num; ?> )</a></font></td>
<td width=""><img src="images/freelisting_arrow2.gif" alt=""> <a href=resulttown.php?town=<? echo $townsArray[1]; ?> class="menu"><font size="1" face="Verdana"> <? echo $townsArray[1]; ?> ( <? echo $num1; ?> )</a></font></td>
<td width=""><img src="images/freelisting_arrow2.gif" alt=""> <a href=resulttown.php?town=<? echo $townsArray[2]; ?> class="menu"> <font size="1" face="Verdana"> <? echo $townsArray[2]; ?> ( <? echo $num2; ?> )</a></font></td>
<td width=""><img src="images/freelisting_arrow2.gif" alt=""> <a href=resulttown.php?town=<? echo $townsArray[3]; ?> class="menu"><font size="1" face="Verdana"> <? echo $townsArray[3]; ?> ( <? echo $num3; ?> )</a></font></td>
</tr>
<tr>
<td width=""><img src="images/freelisting_arrow2.gif" alt=""> <a href=resulttown.php?town=<? echo $townsArray[4]; ?> class="menu"><font size="1" face="Verdana"> <? echo $townsArray[4]; ?> ( <? echo $num4; ?> )</a></font></td>
<td width=""><img src="images/freelisting_arrow2.gif" alt=""> <a href=resulttown.php?town=<? echo $townsArray[5]; ?> class="menu"><font size="1" face="Verdana"> <? echo $townsArray[5]; ?> ( <? echo $num5; ?> )</a></font></td>
<td width=""><img src="images/freelisting_arrow2.gif" alt=""> <a href=resulttown.php?town=<? echo $townsArray[6]; ?> class="menu"><font size="1" face="Verdana"> <? echo $townsArray[6]; ?> ( <? echo $num6; ?> )</a></font></td>
<td width=""><img src="images/freelisting_arrow2.gif" alt=""> <a href=resulttown.php?town=<? echo $townsArray[7]; ?> class="menu"><font size="1" face="Verdana"> <? echo $townsArray[7]; ?> ( <? echo $num7; ?> )</a></font></td>
</tr>
<tr><td height="5"></td></tr>
</table>
regards
roscor