Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Estou com um problema nesta query, ela retorna linhas duplicadas uma em seguida da outra Ex: linha 1 | linha 1 | linha 2 | linha 2 | linha 3| linha3 e assim por diante... Ainda não entendi porque esta acontecendo isso se não vejo o erro na query nem no while... Please me ajudem!!!
Segue codigo abaixo:
<?
require_once("configuracao_mysql.php");
#require_once("includes.php");
$query = array();
if(!empty($_GET[c])) $query[] = "re2_listings.CategoryID = '$_GET[c]' ";
}
if(!empty($_GET[s])) $query[] = "re2_listings.SubcategoryID = '$_GET[s]' ";
}
if(!empty($_GET[AgentID])) $query[] = "re2_listings.AgentID = '$_GET[AgentID]' ";
}
if(!empty($_GET[search_country])) $query[] = "re2_listings.country = '$_GET[search_country]' ";
}
if(!empty($_GET[search_state])) $query[] = "re2_listings.state = '$_GET[search_state]' ";
}
if(!empty($_GET[search_city])) $query[] = "re2_listings.city = '$_GET[search_city]' ";
}
if(!empty($_GET[search_PropertyType])) $query[] = "re2_listings.PropertyType = '$_GET[search_PropertyType]' ";
}
if(!empty($_GET[MinPrice])) $query[] = "re2_listings.price >= '$_GET[MinPrice]' ";
}
if(!empty($_GET[MaxPrice])) $query[] = "re2_listings.price <= '$_GET[MaxPrice]' ";
}
if(!empty($_GET[rooms1])) $query[] = "re2_listings.rooms >= '$_GET[rooms1]' ";
}
if(!empty($_GET[rooms2])) $query[] = "re2_listings.rooms <= '$_GET[rooms2]' ";
}
if(!empty($_GET[bath1])) $query[] = "re2_listings.bathrooms >= '$_GET[bath1]' ";
}
if(!empty($_GET[bath2])) $query[] = "re2_listings.bathrooms <= '$_GET[bath2]' ";
}
if(!empty($_GET[before])) $MyDate = strtotime("-$_GET[before]");
$query[] = "re2_listings.DateAdded >= '$MyDate' ";
}
if(!empty($_GET[school])) $query[] = "re2_listings.NearSchool = 'y' ";
}
if(!empty($_GET[transit])) $query[] = "re2_listings.NearTransit = 'y' ";
}
if(!empty($_GET[park])) $query[] = "re2_listings.NearPark = 'y' ";
}
if(!empty($_GET[ocean_view])) $query[] = "re2_listings.OceanView = 'y' ";
}
if(!empty($_GET[lake_view])) $query[] = "re2_listings.LakeView = 'y' ";
}
if(!empty($_GET[mountain_view])) $query[] = "re2_listings.MountainView = 'y' ";
}
if(!empty($_GET[ocean_waterfront])) $query[] = "re2_listings.OceanWaterfront = 'y' ";
}
if(!empty($_GET[lake_waterfront])) $query[] = "re2_listings.LakeWaterfront = 'y' ";
}
if(!empty($_GET[river_waterfront])) $query[] = "re2_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[] = " re2_listings.DateAdded desc ";
}
if($ov == "Price")
{
$order[] = " re2_listings.Price asc ";
}
if($ov == "address")
{
$order[] = " re2_listings.address asc ";
}
}
}
else
{
if(!empty($_GET[p]))
{
$order[] = " re2_listings.Price asc ";
}
if(!empty($_GET[r]))
{
$order[] = " re2_listings.rooms asc, re2_listings.bathrooms asc, re2_listings.garage asc ";
}
if(!empty($_GET[city]))
{
$order[] = " re2_listings.city, re2_listings.address, re2_listings.state ";
}
}
if(count($order) > '0')
{
$MyOrder = implode(", ", $order);
}
if(empty($MyOrder))
{
$MyOrder = " order by re2_agents.PriorityLevel desc, re2_listings.DateAdded desc";
} $MyOrder = " order by re2_agents.PriorityLevel desc, $MyOrder";
}
if(!empty($_GET[Start])) $Start = $_GET[Start];
} $Start = '0';
}
$ByPage = '10';
$q1 = "select * from re2_listings, re2_agents, re2_priority where re2_listings.AgentID = re2_agents.AgentID and re2_agents.PriorityLevel = re2_priority.PriorityLevel and re2_agents.AccountStatus = 'active' $MyQuery $MyOrder limit $Start, $ByPage ";
$qnav = "select * from re2_listings, re2_agents where re2_listings.AgentID = re2_agents.AgentID $MyQuery";
$r1 = mysql_query($q1) or die(mysql_error());
$lrows = mysql_num_rows($r1);
if($lrows > '0')
{ ?>
<link href="../css/propdetails.css" rel="stylesheet" type="text/css" />
<div id="content">
<div style="outline-color: #CCCCCC; outline-style: solid; outline-width: 1px;" id="properties">
<div id="propPager"></div>
<ul id="searchButton">
<li><a href="#" name="pd" id="pd">RESULTADO DA BUSCA</a></li>
</ul>
<div id="propDetails"><!-- right -->
<div class="quemsomos">
<?php
while($a1 = mysql_fetch_array($r1))
{ ?>
<table align="center" width="90%">
<tr>
<td width="178"><?
if(!empty($a1[image]))
{
$images = explode("|", $a1[image]);
$MyImage = $images[0];
?>
<a href="index.php?page=detalhes-imovel&id=<?=$a1[ListingID]?>"><img src="fotos_anuncios/<?=$MyImage?>" width="112" height="83" border="1" /></a>
<?
}
else
{ ?>
<a href="index.php?page=detalhes-imovel&id=<?=$a1[ListingID]?>"><img src="images/thumb-no-image.jpg" width="112" height="83" border="1" /></a>
<?
} ?> </td>
<td width="144" valign="top"><p><b>Cod. Imóvel:
<?=$a1[ListingID]?>
</b><br />
<?=$a1[city]?>
,
<?=$a1[state]?>
<br />
<?=$a1[address]?>
<br />
<?=$a1[ShortDesc]?>
</p>
</td>
<td width="194" valign="top"><?=$a1[rooms]?>
quarto(s),
<?=$a1[bathrooms]?>
banheiro(s)
<?
if($a1[garage] > '0')
{
?>
,
<?=$a1[garage]?>
garagem(ns)
<? }
$MyPrice = number_format($a1[Price], 2, ",", ".");
?> </td>
<td width="96" align="center" valign="top"><b>R$
<?=$MyPrice?>
</b></td>
</tr>
<tr>
<td colspan="4"> </td>
</tr>
</table>
<?
}
$rnav = mysql_query($qnav) or die(mysql_error());
$rows = mysql_num_rows($rnav);
if($rows > $ByPage)
{
?>
<br />
<table align=center width=90%>
<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=\"index.php?page=buscador&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);
Print $links2;
?>
</font></td>
</table>
<div align="center"><br />
<?
}
}{ ?>
<br />
<br />
Nenhum resultado encontrado!
<?
}
?>
</div>
</div>
</div><!-- propDetails -->
</div>
</div><!--Content-->Carregando comentários...