A bit more clear..also with code
on the site www.forwardestates.co.uk you can search for properties using the search bars to the left of the screen. however, when the page refreshes to show the search results the search form to the left no longer works i.e. the fields for 'property' and 'areas' are now blank. The funny thing is that it is using the same code for both screen as the file searchform.php is included into both pages.
The last point to mention is that it works fine on localhost:8080, its just the live version thats doesnt work.
Here is the code for searchtosell.php and below is searchform.php
ANY ideas or suggestions much appreciated.
searchtosell.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Estate agents, Letings, Global Property Managemnet</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<center>
<table id="tableAll" cellpadding="0" cellspacing="0">
<tr><td valign="top">
<table width="600" cellpadding="0" cellspacing="0">
<tr><td>
<img src="top_ban.jpg">
</td></tr>
</table>
<?php include "mainMenu.php"?>
<table id="search" width="600" cellpadding="0" cellspacing="0">
<tr>
<td width="185px" valign="top" bgcolor="#ffcccc">
<?php include "searchform.php"?>
</td>
<td id="main" valign="top">
<?php
include "linkdb.php";
if ($POST['areas'] == 'All areas') {
$query = "SELECT selling_method, selling_id, types_name, selling_price, selling_rooms, areas_name, selling_image1
FROM selling
JOIN areas
JOIN types
ON selling_area = areas_id AND selling_type = types_id
WHERE (selling_method = 'both' or selling_method = 'toSell') AND
types_name = '" . $POST['types'] . "' AND
selling_rooms >= '" . $POST['rooms'] . "' AND
selling_price <= '" . $POST['price'] . "'";
$result = mysql_query($query,$link) or die(mysql_error());
$num_movies = mysql_num_rows($result);
}
else {
$query = "SELECT selling_method, selling_id, types_name, selling_price, selling_rooms, areas_name, selling_image1
FROM selling
JOIN areas
JOIN types
ON selling_area = areas_id AND selling_type = types_id
WHERE (selling_method = 'both' or selling_method = 'toSell') AND
types_name = '" . $POST['types'] . "' AND
selling_rooms >= '" . $POST['rooms'] . "' AND
areas_name = '" . $POST['areas'] . "' AND
selling_price <= '" . $POST['price'] . "'";
$result = mysql_query($query,$link) or die(mysql_error());
$num_movies = mysql_num_rows($result);
}
?>
<div id="mainContent">
<img src="title_results.jpg">
<br>
<br>
<?php
$header =<<<EOD
<table id="results" width="95%" cellpadding="2" cellspacing="1" align="center" border="0">
EOD;
if ($num_movies >= 1 ) {
$headers =<<<EOD
<tr>
<th>Image</th>
<th>Type</th>
<th>Bedrooms</th>
<th>Rent PCM</th>
<th>Area</th>
</tr>
EOD;
}
$color = "#ffffff";
while ($rows=mysql_fetch_assoc($result)) {
if ($color == "#ffffff") {
$color = "#eeeeee";
}
else {
$color = "#ffffff";
}
$image1Var = $rows['selling_image1'];
$idVarPic = $rows['selling_id'];
if ($image1Var == '')
{
$idVarNoPic = 'noImage';
}
else {
$idVarNoPic = $rows['selling_id'];
}
$typeVar = $rows['types_name'];
$roomsVar = $rows['selling_rooms'];
$priceVar = $rows['selling_price'];
$areaVar = $rows['areas_name'];
$middle .=<<<EOD
<tr>
<td bgcolor="$color"><a href="propertyDetails.php?selling_id=$idVarPic"><img src="images/thumbs/$idVarNoPic.jpg"></a></td>
<td bgcolor="$color"><a href="propertyDetails.php?selling_id=$idVar">$typeVar</td>
<td bgcolor="$color">$roomsVar</td>
<td bgcolor="$color">£ $pcmVar</td>
<td bgcolor="$color">$areaVar</td>
</tr>
EOD;
}
$movie_footer ="</table>";
print $header;
print $headers;
print $middle;
print $movie_footer;
?>
<h2>We found <?php echo $num_movies;?> properties for sale that matched your search criteria!</h2>
</div>
</td>
</tr>
</table>
<table width="600" cellpadding="0" cellspacing="0">
<tr><td>
<img src="bot_ban.jpg">
</td></tr>
</table>
</td></tr>
</table>
</center>
</body>
</html>
searchform.php
<?php
include "linkdb.php";
$areassql = "SELECT * FROM areas ORDER BY areas_name";
$result = mysql_query($areassql)
or die("Invalid query: " . mysql_error());
while ($row = mysql_fetch_array($result)) {
$areas[$row['areas_id']] = $row['areas_name'];
}
$typessql = "SELECT * FROM types";
$result = mysql_query($typessql)
or die("Invalid query: " . mysql_error());
while ($row = mysql_fetch_array($result)) {
$types[$row['types_id']] = $row['types_name'];
}
?>
<div id="toBuy">
<img src="label_buying.jpg">
<form id="formsearch" action="searchtosell.php" method="post">
<table width="90%" cellpadding="1" cellspacing="0" border="0">
<tr>
<td class="formfont">Property</td>
<td><select name="types">
<option value="">Select</option>
<?php
foreach ($types as $types_id => $types_name) {
?>
<option value="<?php echo $types_name; ?>" >
<?php
echo $types_name;
?>
</option>
<?php
}
?>
</select>
</td>
</tr>
<tr>
<td class="formfont">At least</td>
<td class="formfont">
<select name="rooms">
<option value="">Select</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
</select> bedrooms
</td>
</tr>
<tr>
<td class="formfont">Upto £</td>
<td class="formfont">
<select name="price">
<option value="">Select</option>
<option>100000</option>
<option>200000</option>
<option>300000</option>
<option>400000</option>
<option>500000</option>
<option>600000</option>
</select>
</td>
</tr>
<tr>
<td class="formfont">Areas</td>
<td>
<select name="areas">
<option value="">Select</option>
<option>All areas</option>
<?php
foreach ($areas as $areas_id => $areas_name) {
?>
<option value="<?php echo $areas_name; ?>" >
<?php
echo $areas_name;
?>
</option>
<?php
}
?>
</select>
</td>
</tr>
</table>
<input type="submit" name="submit" value="Search">
</form>
</div>
<div id="toLet">
<img src="label_letting.jpg">
<form id="formsearch" action="searchtolet.php" method="post">
<table width="90%" cellpadding="1" cellspacing="0">
<tr>
<td class="formfont2">Property</td>
<td><select name="types">
<option value="">Select</option>
<?php
foreach ($types as $types_id => $types_name) {
?>
<option value="<?php echo $types_name; ?>" >
<?php
echo $types_name;
?>
</option>
<?php
}
?>
</select>
</td>
</tr>
<tr>
<td class="formfont2">At least</td>
<td class="formfont2">
<select name="rooms">
<option value="">Select</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
</select> bedrooms
</td>
</tr>
<tr>
<td class="formfont2">Upto £</td>
<td class="formfont2">
<select name="pcm">
<option value="">Select</option>
<option>300</option>
<option>400</option>
<option>500</option>
<option>600</option>
<option>700</option>
<option>800</option>
<option>900</option>
<option>1000</option>
<option>1100</option>
<option>1200</option>
<option>1300</option>
<option>1400</option>
</select> pcm
</td>
</tr>
<tr>
<td class="formfont2">Areas</td>
<td>
<select name="areas">
<option value="">Select</option>
<option>All areas</option>
<?php
foreach ($areas as $areas_id => $areas_name) {
?>
<option value="<?php echo $areas_name; ?>" >
<?php
echo $areas_name;
?>
</option>
<?php
}
?>
</select>
</td>
</tr>
</table>
<input type="submit" name="submit" value="Search">
</form>
</div>
<div id="featured">
<?php
$featured = "SELECT featured_num FROM featured WHERE featured_id = 1";
$result = mysql_query($featured) or die(mysql_error());
$row = mysql_fetch_array($result);
$featured_num = $row['featured_num'];
$allsql = "SELECT * FROM selling
JOIN areas
JOIN types
ON selling_area = areas_id AND selling_type = types_id
WHERE selling_id = $featured_num";
$result = mysql_query($allsql,$link) or die(mysql_error());
$row = mysql_fetch_array($result, MYSQL_ASSOC );
$selling_id = $row['selling_id'];
$selling_rooms = $row['selling_rooms'];
$selling_type = $row['types_name'];
$selling_area = $row['areas_name'];
$selling_price = $row['selling_price'];
$selling_method = $row['selling_method'];
$selling_image1 = $row['selling_image1'];
if ($selling_image1 == "") {
$selling_id2 = "noImage";
}
else {
$selling_id2 = $row['selling_id'];
}
if ($selling_method == "Both") {
$method = "available to buy or rent";
}
else if ($selling_method == "toLet") {
$method = "available to let";
}
else if ($selling_method == "toSell") {
$method = "available to buy";
}
if ($selling_type == "Flat") {
$property = "";
}
else {
$property = "property";
}
$featured =<<<EOD
<table width="85%" cellpadding="0" cellspacing="0" border="0">
<tr>
<th colspan="2">Featured Property</th>
</tr>
<tr>
<td width="50%">
<a href="propertyDetails.php?selling_id=$selling_id"><img src="images/thumbs/$selling_id2.jpg"></a>
</td>
<td class="id">ID: JB0$selling_id</style></td>
</tr>
<tr>
<td colspan="2">
Currently $method this is a $selling_rooms bedroom $selling_type $property located in $areas_name.</td>
</tr>
<tr>
<td colspan="2">
<a href="propertyDetails.php?selling_id=$selling_id">More details</a>
</td>
</tr>
</table>
EOD;
print $featured;
?>
</div>