PHP Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<?php
$connection = mysql_connect('localhost', 'username', 'password');
if (!$connection)
{
echo "There was an Error connecting to the Database. Please try again later.<br>";
}
$db = mysql_select_db('NinjaRap', $connection);
$limit = 25;
$City = strip_tags($City);
$City = trim ($City);
$YearMin = strip_tags($YearMin);
$YearMin = trim ($YearMin);
$YearMax = strip_tags($YearMax);
$YearMax = trim ($YearMax);
$TypeSelection = "";
$key = array();
foreach ($_POST['mlstype'] as $key[] => $value)
$TypeSelection = implode("','", $key);
If ($TypeSelection == "")
{
$TypeSelection = "Single Family', 'Single Family w/ Acreage', 'Condo', 'Mobile/Manu Rented Lot',
'Mobile/Manu Owned Lot', 'Recreational Land w/ Home', 'Townhouse', 'Business', 'Commercial', 'Industrial', 'Office', 'Other', 'Retail',
'Agricultural', 'Build to Suit Commercial', 'Build to Suit Residential', 'Building Lots', 'Development', 'Recreation',
'Apartment', 'Duplex', 'Fourplex', 'Triplex', 'Dairy', 'Farm', 'Multi Use', 'Ranch";
}
If (!$date = checkdate(02,04,$YearMin))
{
$YearMin = "1500";
}
If ($YearMax == "")
{
$YearMax = date(Y)+10;
}
$AcresQuery = " AND mlsacres BETWEEN " . $Acreage . " ";
$AgeQuery = "";
$BathsQuery = " AND mlsbaths " . $Baths . " ";
$BedsQuery = " AND mlsbeds " . $Beds . " ";
$GarageCapQuery = " AND mlsgaragecapacity " . $Garage . " ";
$LandSizeQuery = "";
$LandUseQuery = "";
$LevelsQuery = " AND mlslevel " . $mlsLevels . " ";
$ParkingQuery = "";
$ResInclQuery = "";
$SqftQuery = " AND mlssqft " . $sqfoot . " ";
$SubDivQuery = "";
$UnitsQuery = "";
$YearBuiltQuery = " AND mlsyearbuilt BETWEEN '" . $YearMin . "' AND '" . $YearMax . "' ";
If ($PropertyClass == "= 'Residential'")
{
$ParkingQuery = "";
$UnitsQuery = "";
$SubDivQuery = "";
$LandUseQuery = "";
$LandSizeQuery = "";
$AgeQuery = "";
$ResInclQuery = "";
}
If ($PropertyClass == "= 'Business/Commercial'")
{
$AcresQuery = "";
$SubDivQuery = "";
$ResInclQuery = "";
$BathsQuery = "";
$BedsQuery = "";
$ParkingQuery = "";
$UnitsQuery = "";
$YearBuiltQuery = "";
$GarageCapQuery = "";
$LevelsQuery = "";
}
If ($PropertyClass == "= 'Farm & Ranch'")
{
$LandSizeQuery = "";
$LandUseQuery = "";
$SubDivQuery = "";
$SqftQuery = "";
$ParkingQuery = "";
$UnitsQuery = "";
$YearBuiltQuery = "";
$GarageCapQuery = "";
$LevelsQuery = "";
}
If ($PropertyClass == "= 'Residential Income'")
{
$AcresQuery = "";
$ResInclQuery = "";
$SqftQuery = "";
$BathsQuery = "";
$BedsQuery = "";
$YearBuiltQuery = "";
$GarageCapQuery = "";
$LevelsQuery = "";
}
If ($PropertyClass == "= 'Land'")
{
$AgeQuery = "";
$ResInclQuery = "";
$SqftQuery = "";
$BathsQuery = "";
$BedsQuery = "";
$ParkingQuery = "";
$UnitsQuery = "";
$YearBuiltQuery = "";
$GarageCapQuery = "";
$LevelsQuery = "";
}
$table_query = "SELECT * FROM tblmls WHERE mlsclass " . $PropertyClass . "
AND mlsstatus IN('Active', 'New', 'Back on Market', 'Price Change', 'Contingent Finance', 'Contingent Sale', 'Contingent Multiple', 'Contingent Other')
AND mlscity LIKE '%" . $City ."%'
AND mlslistprice BETWEEN '" . $PriceMin . "' AND '" . $PriceMax . "'
AND mlstype IN ('". $TypeSelection . "' )
$AcresQuery
$AgeQuery
$BathsQuery
$BedsQuery
$GarageCapQuery
$LandSizeQuery
$LandUseQuery
$LevelsQuery
$ParkingQuery
$ResInclQuery
$SqftQuery
$SubDivQuery
$UnitsQuery
$YearBuiltQuery
";
$query_result = mysql_query ($table_query, $connection);
$totalrows = mysql_num_rows($query_result);
if(empty($page)){
$page = 1;
}
$limitvalue = $page * $limit - ($limit);
mysql_free_result($query_result);
$table_query = "SELECT * FROM tblmls WHERE mlsclass " . $PropertyClass . "
AND mlsstatus IN('Active', 'New', 'Back on Market', 'Price Change', 'Contingent Finance', 'Contingent Sale', 'Contingent Multiple', 'Contingent Other')
AND mlscity LIKE '%" . $City ."%'
AND mlslistprice BETWEEN '" . $PriceMin . "' AND '" . $PriceMax . "'
AND mlstype IN ('". $TypeSelection . "' )
$AcresQuery
$AgeQuery
$BathsQuery
$BedsQuery
$GarageCapQuery
$LandSizeQuery
$LandUseQuery
$LevelsQuery
$ParkingQuery
$ResInclQuery
$SqftQuery
$SubDivQuery
$UnitsQuery
$YearBuiltQuery
LIMIT $limitvalue, $limit
";
$query_result = mysql_query ($table_query, $connection);
Print "<form method='POST' action='form3.html'>\n";
?>
<body>
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr align="center">
<td colspan="3">header</td>
</tr>
<tr>
<td width="15%"> </td>
<td width="70%" align="center">Content Header </td>
<td width="15%"> </td>
</tr>
<tr>
<td width="15%"><div align="left">Banneres Tables</div></td>
<td width="70%" align="center"><table width="100%" height="104" border="1" cellpadding="0" cellspacing="0">
<tr>
<?php
While ($row = mysql_fetch_object($query_result))
{
print "\t<tr>";
print "\t\t<td width='100' height='120'> <a href=details3.php?MLSID=" . $row->mlsnumber . "><img src='\images\AsianDT.jpg'vspace=22 hspace=22 width='78' height='104'></a>";
print "\t\t<td border='1'>";
print "\t\t Price: $" . number_format($row->mlslistprice,"","",",") . "<br>";
print "\t\t City: " . $row->mlscity . "<br>";
print "\t\t Beds: " . $row->mlsbeds . "<br>";
print "\t\t Baths: " . $row->mlsbaths . "<br>";
print "\t\t</td>";
print "\t\t<td>";
print "\t\t <a href=details3.php?MLSID=" . $row->mlsnumber . ">See Details</a>";
print "\t\t <a href=details3.php?MLSID=" . $row->mlsnumber . ">See Pictures</a>";
print "\t\t</td>";
print "\t</tr>";
}
mysql_free_result($query_result);
mysql_close($connection);
if($page != 1){
$pageprev = $page-1;
echo("<a href=\"$PHP_SELF?page=$pageprev\">PREV".$limit."</a> ");
}else{
echo("PREV".$limit." ");
}
$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++;
echo("<a href=\"$PHP_SELF?page=$pagenext\">NEXT".$limit."</a>");
}else{
echo("NEXT".$limit);
}
echo $page; echo "page<br>";
echo $totalrows; echo "totalrows<br>";
echo $limit; echo "limit<br>";
echo $pagenext; echo "pagenext<br>";
echo $numofpages; echo "numofpages<br>";
echo $pageprev; echo "pageprev<br>";
?>
From what I have been reading most people will put this information into the URL, my issue with that is that I will be running rather large queries that could possibly search all 350 some odd fields by the time that I am done. And storing all that into the URL to me seems kind of bad. There are also some people that will store all this information in a cookie on the client machine. My understanding of cookies is that there is a limit to the size and storing this kind of information in a cookie probably isn't the best idea.
Bookmarks