Hi
I have created a simple form to do searches on, but on submission the results are not correct and I cannot work out why!!
I have 2 php pages the first is as follows:
<HTML>
<HEAD><TITLE>Search for your property</TITLE></HEAD>
<BODY>
<p align="right"><strong><<<<< BASIC SEARCH</strong></p>
<p> </p>
<p align="left"> <strong>[font=Century Gothic]
<?php
# FROM AND TO PRICES LISTBOXES
echo "<FORM METHOD=POST ACTION='propertyfinder.php'>";
echo "Basic property search test base";
echo "<BR><BR>";
echo "Price?";
echo "<BR><BR>";
echo "From: ";
echo "<SELECT NAME='From_Price'>";
$Bottom=array("85000", "95000", "110000", "120000", "130000", "140000", "150000", "160000", "170000", "180000", "190000", "220000");
echo "<OPTION VALUE=$Bottom[0]>$Bottom[0]</OPTION>";
echo "<OPTION VALUE=$Bottom[1]>$Bottom[1]</OPTION>";
echo "<OPTION VALUE=$Bottom[2]>$Bottom[2]</OPTION>";
echo "<OPTION VALUE=$Bottom[3]>$Bottom[3]</OPTION>";
echo "<OPTION VALUE=$Bottom[4]>$Bottom[4]</OPTION>";
echo "<OPTION VALUE=$Bottom[5]>$Bottom[5]</OPTION>";
echo "<OPTION VALUE=$Bottom[6]>$Bottom[6]</OPTION>";
echo "<OPTION VALUE=$Bottom[7]>$Bottom[7]</OPTION>";
echo "<OPTION VALUE=$Bottom

>$Bottom

</OPTION>";
echo "<OPTION VALUE=$Bottom[9]>$Bottom[9]</OPTION>";
echo "<OPTION VALUE=$Bottom[10]>$Bottom[10]</OPTION>";
echo "<OPTION VALUE=$Bottom[11]>$Bottom[11]</OPTION>";
echo "</SELECT>";
echo " ";
echo "To: ";
echo "<SELECT NAME='To_Price'>";
$Top=array("85000", "95000", "110000", "120000", "130000", "140000", "150000", "160000", "170000", "180000", "190000", "220000");
echo "<OPTION VALUE=$Top[0]>$Top[0]</OPTION>";
echo "<OPTION VALUE=$Top[1]>$Top[1]</OPTION>";
echo "<OPTION VALUE=$Top[2]>$Top[2]</OPTION>";
echo "<OPTION VALUE=$Top[3]>$Top[3]</OPTION>";
echo "<OPTION VALUE=$Top[4]>$Top[4]</OPTION>";
echo "<OPTION VALUE=$Top[5]>$Top[5]</OPTION>";
echo "<OPTION VALUE=$Top[6]>$Top[6]</OPTION>";
echo "<OPTION VALUE=$Top[7]>$Top[7]</OPTION>";
echo "<OPTION VALUE=$Top

>$Top

</OPTION>";
echo "<OPTION VALUE=$Top[9]>$Top[9]</OPTION>";
echo "<OPTION VALUE=$Top[10]>$Top[10]</OPTION>";
echo "<OPTION VALUE=$Top[11]>$Top[11]</OPTION>";
echo "</SELECT><BR><BR>";
# BEDROOMS DROP DOWN LIST BOX
echo "Minimum number of bedrooms?";
echo "<BR><BR>";
echo "<SELECT NAME='Bedrooms'>";
$Rooms=array("1", "2", "3", "4", "5", "6");
echo "<OPTION VALUE=$Rooms[0]>$Rooms[0]</OPTION>";
echo "<OPTION VALUE=$Rooms[1]>$Rooms[1]</OPTION>";
echo "<OPTION VALUE=$Rooms[2]>$Rooms[2]</OPTION>";
echo "<OPTION VALUE=$Rooms[3]>$Rooms[3]</OPTION>";
echo "<OPTION VALUE=$Rooms[4]>$Rooms[4]</OPTION>";
echo "<OPTION VALUE=$Rooms[5]>$Rooms[5]</OPTION>";
echo "</SELECT>";
echo "<BR><BR>";
# PROPERTY TYPE DROP DOWN LIST
echo "Property type?";
echo "<BR><BR>";
echo "<SELECT NAME='Prop_Type'>";
$Type=array("house", "bungalow", "flat", "caravan", "cardboard_box", "other");
echo "<OPTION VALUE=$Type[0]>$Type[0]</OPTION>";
echo "<OPTION VALUE=$Type[1]>$Type[1]</OPTION>";
echo "<OPTION VALUE=$Type[2]>$Type[2]</OPTION>";
echo "<OPTION VALUE=$Type[3]>$Type[3]</OPTION>";
echo "<OPTION VALUE=$Type[4]>$Type[4]</OPTION>";
echo "<OPTION VALUE=$Type[5]>$Type[5]</OPTION>";
echo "</SELECT>";
echo "<BR><BR>";
# LOCATION INFORMATION
echo "Location?";
echo "<BR><BR>";
echo "<INPUT NAME='Location' TYPE='TEXT'>";
echo "<BR><BR>";
echo "<INPUT TYPE=SUBMIT VALUE='Find a property!!'>";
echo "</FORM>";
?>
</strong>
</BODY>
</HTML>
The second being:
<?php
include "./common_db2.inc";
echo "<p align='right'><strong><<<<< YOUR RESULTS</strong></p>";
echo "<p> </p>";
echo "[center]<p><strong>You have searched for a " . $_REQUEST['Prop_Type'] . " with " . $_REQUEST['Bedrooms'] . " bedroom(s) priced from $" . $_REQUEST['From_Price'] . " to $". $_REQUEST['To_Price'] . "</strong></p>";
if ($_REQUEST['From_Price'] > $_REQUEST['To_Price']) {
echo("<p><div align='center'>[font=Century Gothic]<strong>Your Starting Price is higher than your Maximum Price!</strong></div></p>");
echo "<p> </p>";
echo "<p> </p>";
echo "<strong><a href='listbox2.php'>< Amend my Search ></a></strong>";
exit();
}
$link_id = db_connect();
$result = mysql_query("SELECT * FROM prices WHERE price >= $_POST[From_Price] AND price <= $_POST[To_Price] AND bedrooms >= $_POST[Bedrooms] AND prop_type = '$_POST[Prop_Type]' ORDER BY price", $link_id);
$row = mysql_fetch_array($result);
if (!$row) {
echo("<p><div align='center'>[font=Century Gothic]<strong>Sorry, no matching properties found!</strong></div></p>");
echo "<p> </p>";
echo "<p> </p>";
echo "<strong><a href='listbox2.php'>< Try Another Search ></a></strong>";
exit();
}
while($query_data = mysql_fetch_row($result)) {
echo "Property no ",$query_data[0]," is a ",$query_data[3]," and is priced $",$query_data[1],","," and has ",$query_data[2]," bedroom(s)","<P>";
}
echo mysql_fetch_array($result);
echo "<strong><a href='listbox2.php'>< Try Another Search ></a></strong>";
?>
When I do a search on values from 110000 to 110000 I donât get a result, nor do I get a message saying âSorry, no matching properties found!â. This tells me that the query is finding a result despite it not being displayed. This also happens with other searches where results are inaccurate â my database has approx 60 records with a variety of values varying from 110000 to 205000.
Sorry that this post is so long, I thought that I should give as much information as possible!!
I anyone has any idea on where Iâm going wrong, please let me know.
Many thanks in advance
Jamal