aí vai o código do
search.php:
<?
require_once("conn.php");
require_once("includes.php");
$query = array();
if(!empty($_GET[c]))
{
$query[] = "re_listings.CategoryID = '$_GET[c]' ";
}
if(!empty($_GET[s]))
{
$query[] = "re_listings.SubcategoryID = '$_GET[s]' ";
}
if(!empty($_GET[AgentID]))
{
$query[] = "re_listings.AgentID = '$_GET[AgentID]' ";
}
if(!empty($_GET[search_country]))
{
$query[] = "re_listings.country = '$_GET[search_country]' ";
}
if(!empty($_GET[search_state]))
{
$query[] = "re_listings.state = '$_GET[search_state]' ";
}
if(!empty($_GET[search_city]))
{
$query[] = "re_listings.city = '$_GET[search_city]' ";
}
if(!empty($_GET[search_PropertyType]))
{
$query[] = "re_listings.PropertyType = '$_GET[search_PropertyType]' ";
}
if(!empty($_GET[MinPrice]))
{
$query[] = "re_listings.price >= '$_GET[MinPrice]' ";
}
if(!empty($_GET[MaxPrice]))
{
$query[] = "re_listings.price <= '$_GET[MaxPrice]' ";
}
if(!empty($_GET[rooms1]))
{
$query[] = "re_listings.rooms >= '$_GET[rooms1]' ";
}
if(!empty($_GET[rooms2]))
{
$query[] = "re_listings.rooms <= '$_GET[rooms2]' ";
}
if(!empty($_GET[bath1]))
{
$query[] = "re_listings.bathrooms >= '$_GET[bath1]' ";
}
if(!empty($_GET[bath2]))
{
$query[] = "re_listings.bathrooms <= '$_GET[bath2]' ";
}
if(!empty($_GET[before]))
{
$MyDate = strtotime("-$_GET[before]");
$query[] = "re_listings.DateAdded >= '$MyDate' ";
}
if(!empty($_GET[school]))
{
$query[] = "re_listings.NearSchool = 'y' ";
}
if(!empty($_GET[transit]))
{
$query[] = "re_listings.NearTransit = 'y' ";
}
if(!empty($_GET[park]))
{
$query[] = "re_listings.NearPark = 'y' ";
}
if(!empty($_GET[ocean_view]))
{
$query[] = "re_listings.OceanView = 'y' ";
}
if(!empty($_GET[lake_view]))
{
$query[] = "re_listings.LakeView = 'y' ";
}
if(!empty($_GET[mountain_view]))
{
$query[] = "re_listings.MountainView = 'y' ";
}
if(!empty($_GET[ocean_waterfront]))
{
$query[] = "re_listings.OceanWaterfront = 'y' ";
}
if(!empty($_GET[lake_waterfront]))
{
$query[] = "re_listings.LakeWaterfront = 'y' ";
}
if(!empty($_GET[river_waterfront]))
{
$query[] = "re_listings.RiverWaterfront = 'y' ";
}
if(!empty($query))
{
$MyQuery = implode(" and ", $query);
$MyQuery = "and ".$MyQuery;
}
////////////////////////////////////////////////////////////
////////// order by
$order = array();
if(!empty($_GET[orderby]))
{
$MyOrder = explode("|", $_GET[orderby]);
while(list(,$ov) = each($MyOrder))
{
if($ov == "DateAdded")
{
$order[] = " re_listings.DateAdded desc ";
}
if($ov == "Price")
{
$order[] = " re_listings.Price asc ";
}
if($ov == "address")
{
$order[] = " re_listings.address asc ";
}
}
}
else
{
if(!empty($_GET[p]))
{
$order[] = " re_listings.Price asc ";
}
if(!empty($_GET[r]))
{
$order[] = " re_listings.rooms asc, re_listings.bathrooms asc, re_listings.garage asc ";
}
if(!empty($_GET[city]))
{
$order[] = " re_listings.city, re_listings.address, re_listings.state ";
}
}
if(count($order) > '0')
{
$MyOrder = implode(", ", $order);
}
if(empty($MyOrder))
{
$MyOrder = " order by re_agents.PriorityLevel desc, re_listings.DateAdded desc";
}
else
{
$MyOrder = " order by re_agents.PriorityLevel desc, $MyOrder";
}
if(!empty($_GET[Start]))
{
$Start = $_GET[Start];
}
else
{
$Start = '0';
}
$ByPage = '20';
$q1 = "select * from re_listings, re_agents, re_priority where re_listings.AgentID = re_agents.AgentID and re_agents.PriorityLevel = re_priority.PriorityLevel and re_agents.AccountStatus = 'active' $MyQuery $MyOrder limit $Start, $ByPage ";
$qnav = "select * from re_listings, re_agents where re_listings.AgentID = re_agents.AgentID $MyQuery";
$r1 = mysql_query($q1) or die(mysql_error());
$lrows = mysql_num_rows($r1);
if($lrows > '0')
{
$ListingTable .= "<table align=center width=590 cellspacing=0>\n";
$ListingTable .= "<tr>\n<td width=75> </td>\n\t";
$ListingTable .= "<td width=200 align=center><a class=BlackLink href=\"search.php?c=$_GET[c]&s=$_GET[s]&AgentID=$_GET[AgentID]&search_city=$_GET[search_city]&search_state=$_GET[search_state]&search_country=$_GET[search_country]&search_PropertyType=$_GET[search_PropertyType]&MinPrice=$_GET[MinPrice]&MaxPrice=$_GET[MaxPrice]&rooms1=$_GET[rooms1]&rooms2=$_GET[rooms2]&bath1=$_GET[bath1]&bath2=$_GET[bath2]&before=$_GET[before]&school=$_GET[school]&transit=$_GET[transit]&park=$_GET[park]&ocean_view=$_GET[ocean_view]&lake_view=$_GET[lake_view]&mountain_view=$_GET[mountain_view]&ocean_waterfront=$_GET[ocean_waterfront]&lake_waterfront=$_GET[lake_waterfront]&river_waterfront=$_GET[river_waterfront]&city=1\">endereço</a></td>\n\t";
$ListingTable .= "<td width=125 align=center><a class=BlackLink href=\"search.php?c=$_GET[c]&s=$_GET[s]&AgentID=$_GET[AgentID]&search_city=$_GET[search_city]&search_state=$_GET[search_state]&search_country=$_GET[search_country]&search_PropertyType=$_GET[search_PropertyType]&MinPrice=$_GET[MinPrice]&MaxPrice=$_GET[MaxPrice]&rooms1=$_GET[rooms1]&rooms2=$_GET[rooms2]&bath1=$_GET[bath1]&bath2=$_GET[bath2]&before=$_GET[before]&school=$_GET[school]&transit=$_GET[transit]&park=$_GET[park]&ocean_view=$_GET[ocean_view]&lake_view=$_GET[lake_view]&mountain_view=$_GET[mountain_view]&ocean_waterfront=$_GET[ocean_waterfront]&lake_waterfront=$_GET[lake_waterfront]&river_waterfront=$_GET[river_waterfront]&r=1\">quar, banh, gara</a></td>\n\t";
$ListingTable .= "<td align=center width=100><a class=BlackLink href=\"search.php?c=$_GET[c]&s=$_GET[s]&AgentID=$_GET[AgentID]&search_city=$_GET[search_city]&search_state=$_GET[search_state]&search_country=$_GET[search_country]&search_PropertyType=$_GET[search_PropertyType]&MinPrice=$_GET[MinPrice]&MaxPrice=$_GET[MaxPrice]&rooms1=$_GET[rooms1]&rooms2=$_GET[rooms2]&bath1=$_GET[bath1]&bath2=$_GET[bath2]&before=$_GET[before]&school=$_GET[school]&transit=$_GET[transit]&park=$_GET[park]&ocean_view=$_GET[ocean_view]&lake_view=$_GET[lake_view]&mountain_view=$_GET[mountain_view]&ocean_waterfront=$_GET[ocean_waterfront]&lake_waterfront=$_GET[lake_waterfront]&river_waterfront=$_GET[river_waterfront]&p=1\">preço</a></td>\n";
$ListingTable .= "</tr>\n</table>\n\n";
$ListingTable .= "<table align=center width=590 border=1 bordercolor=#993333 rules=rows cellspacing=0>\n";
while($a1 = mysql_fetch_array($r1))
{
$ListingTable .= "<tr style=\"border-width:1; border-color:blue\" onMouseOver=\"this.style.background='#dddddd'; this.style.cursor='hand'\" onMouseOut=\"this.style.background='#ffffff'\" onClick=\"window.open('info.php?id=$a1[ListingID]', '_top')\">\n\t";
$ListingTable .= "<td height=60>";
$ListingTable .= "<table align=center width=\"100%\">\n";
$ListingTable .= "<caption align=center><span class=RedLink>Lista $a1[PriorityName]</span></caption>\n";
$ListingTable .= "<tr>\n\t<td width=75>";
if(!empty($a1[image]))
{
$images = explode("|", $a1[image]);
$MyImage = $images[0];
$ListingTable .= "<img src=\"re_images/$MyImage\" width=75 height=60 border=1>";
}
else
{
$ListingTable .= "<img src=\"no_image.gif\" border=1>";
}
$ListingTable .= "</td>\n\t";
$ListingTable .= "<td width=225 valign=top><b>Propriedade ID: $a1[ListingID]</b><br>$a1[city], $a1[state]<br>$a1[address], $a1[country]</td>\n\t";
$ListingTable .= "<td width=100 valign=top>$a1[rooms] qu, $a1[bathrooms] ba";
if($a1[garage] > '0')
{
$ListingTable .= ", $a1[garage] gr";
}
$MyPrice = number_format($a1[Price], 2, ".", "'");
$ListingTable .= "</td>\n\t<td align=center width=100 valign=top><b>R$$MyPrice</td>\n";
$ListingTable .= "</tr>\n";
$ListingTable .= "<tr>\n\t<td colspan=4>$a1[ShortDesc]</td>\n</tr>\n";
$ListingTable .= "</table>\n\n</td>\n</tr>\n\n";
}
$ListingTable .= "</table>";
$rnav = mysql_query($qnav) or die(mysql_error());
$rows = mysql_num_rows($rnav);
if($rows > $ByPage)
{
$ListingTable .= "<br><table align=center width=580>";
$ListingTable .= "<td align=center><font face=verdana size=2> | ";
$pages = ceil($rows/$ByPage);
for($i = 0; $i <= ($pages); $i++)
{
$PageStart = $ByPage*$i;
$i2 = $i + 1;
if($PageStart == $Start)
{
$links[] = " <span class=RedLink>$i2</span>\n\t ";
}
elseif($PageStart < $rows)
{
$links[] = " <a class=BlackLink href=\"search.php?Start=$PageStart&c=$_GET[c]&s=$_GET[s]&AgentID=$_GET[AgentID]&search_city=$_GET[search_city]&search_state=$_GET[search_state]&search_country=$_GET[search_country]&search_PropertyType=$_GET[search_PropertyType]&MinPrice=$_GET[MinPrice]&MaxPrice=$_GET[MaxPrice]&rooms1=$_GET[rooms1]&rooms2=$_GET[rooms2]&bath1=$_GET[bath1]&bath2=$_GET[bath2]&before=$_GET[before]&school=$_GET[school]&transit=$_GET[transit]&park=$_GET[park]&ocean_view=$_GET[ocean_view]&lake_view=$_GET[lake_view]&mountain_view=$_GET[mountain_view]&ocean_waterfront=$_GET[ocean_waterfront]&lake_waterfront=$_GET[lake_waterfront]&river_waterfront=$_GET[river_waterfront]&city=$_GET[city]&p=$_GET[p]&r=$_GET[r]\">$i2</a>\n\t ";
}
}
$links2 = implode(" | ", $links);
$ListingTable .= $links2;
$ListingTable .= "| </td>";
$ListingTable .= "</table><br>\n";
}
}
else
{
$ListingTable = "<br><br><center>Nenhum resultado encontrado!</center>";
}
require_once("templates/HeaderTemplate.php");
require_once("templates/SearchTemplate.php");
require_once("templates/FooterTemplate.php");
?>
Quem tiver interesse em tentar dar uma ajeitada no código entre em contato que eu passo todo o script sem custo nenhum.

é só dar um toque!
O Administrador
Crab_ já tá com o script em mãos e tá dando uma olhada!
Edição feita por: murillodocarmo, 26/04/2005, 08:11.