...

View Full Version : Returning duplicate results - why??



CGDesigns
02-01-2010, 09:16 PM
Returning duplicate results - why??
My search code is returning duplicate results for one item searched. And it's the same exact result. I understand if a certain item is in there multiple times for whatever reason, but that's not the case. It's returning the same results - duplicates - like 10 or more times in a row. On the same page. Why is it doing this? It was not doing this before!

This is what I'm using for my search query:




$query = "SELECT asmnt_parcel.Account, asmnt_parcel.OwnersName, asmnt_parcel.ParcelID, asmnt_parcel.Township, asmnt_parcel.Range, asmnt_parcel.Section, asmnt_parcel.LotSize, asmnt_parcel.LotSizeType, asmnt_parcel.TaxAreaCode, asmnt_parcel.TotalValue, asmnt_legal.Legal, cmn_name.Address2, cmn_name.City, cmn_name.State, cmn_name.ZipCode, asmnt_situs.Situs, appr_resident.TotalArea, appr_resident.YearBuilt, appr_miscimpr.Description, appr_miscimpr.Year, appr_miscimpr.Size, appr_miscimpr.Value, appr_commercial.CostValue, appr_commercial.BldgDescription, sale_parcel.SaleDate, sale_parcel.SalePrice, sale_parcel.InstrumentNumber
FROM asmnt_parcel
INNER JOIN asmnt_legal
ON asmnt_parcel.Account=asmnt_legal.Account
INNER JOIN cmn_name
ON asmnt_parcel.OwnersName=cmn_name.OwnersName
INNER JOIN asmnt_situs
ON asmnt_parcel.Account=asmnt_situs.Account
INNER JOIN appr_resident
ON asmnt_parcel.Account=appr_resident.Account
INNER JOIN appr_miscimpr
ON asmnt_parcel.Account=appr_miscimpr.Account
LEFT JOIN appr_commercial
ON asmnt_parcel.Account=appr_commercial.Account
LEFT JOIN sale_parcel
ON asmnt_parcel.Account=sale_parcel.Account
WHERE asmnt_parcel.Account = '{$search}' OR asmnt_parcel.OwnersName = '{$search}' OR asmnt_parcel.ParcelID = '{$search}' OR asmnt_legal.Legal = '{$search}'
ORDER BY asmnt_parcel.Account ASC";
$result = mysql_query($query, $con) or die(mysql_error().": $query");

if ($result)
{
echo "Results:<br><br>";
echo "<table width=90% align=center border=1><tr>
<td align=center bgcolor=#4A6B3F>Account</td>
<td align=center bgcolor=#4A6B3F>Owners Name</td>
<td align=center bgcolor=#4A6B3F>Address</td>
<td align=center bgcolor=#4A6B3F>City</td>
<td align=center bgcolor=#4A6B3F>State</td>
<td align=center bgcolor=#4A6B3F>Zip Code</td>
<td align=center bgcolor=#4A6B3F>Legal</td>
<td align=center bgcolor=#4A6B3F>Parcel ID</td>
<td align=center bgcolor=#4A6B3F>Property Size</td>
<td align=center bgcolor=#4A6B3F>Type</td>
<td align=center bgcolor=#4A6B3F>Total Sq. Ft</td>
<td align=center bgcolor=#4A6B3F>Est. Year Built</td>
<td align=center bgcolor=#4A6B3F>Total Value</td>
<td align=center bgcolor=#4A6B3F>Impr. Description</td>
<td align=center bgcolor=#4A6B3F>Impr. Year</td>
<td align=center bgcolor=#4A6B3F>Impr. Size</td>
<td align=center bgcolor=#4A6B3F>Impr. Value</td>
<td align=center bgcolor=#4A6B3F>Cost Value</td>
<td align=center bgcolor=#4A6B3F>Bldg. Description</td>
<td align=center bgcolor=#4A6B3F>Sale Date</td>
<td align=center bgcolor=#4A6B3F>Sale Price</td>
<td align=center bgcolor=#4A6B3F>School District</td>
<td align=center bgcolor=#4A6B3F>Situs</td>
<td align=center bgcolor=#4A6B3F>Township</td>
<td align=center bgcolor=#4A6B3F>Range</td>
<td align=center bgcolor=#4A6B3F>Section</td>
<td align=center bgcolor=#4A6B3F>Book & Page</td>
<td align=center bgcolor=#4A6B3F></td>
</tr>";

while ($r = mysql_fetch_array($result))
{ // Begin while
$act = $r["Account"];
$nme = $r["OwnersName"];
$add = $r["Address2"];
$city = $r["City"];
$ste = $r["State"];
$zip = $r["ZipCode"];
$legal = $r["Legal"];
$pid = $r["ParcelID"];
$size = $r["LotSize"];
$type = $r["LotSizeType"];
$sqft = $r["TotalArea"];
$built = $r["YearBuilt"];
$valu = $r["TotalValue"];
$impr = $r["Description"];
$iyr = $r["Year"];
$isze = $r["Size"];
$ivlu = $r["Value"];
$cost = $r["CostValue"];
$bldg = $r["BldgDescription"];
$date = $r["SaleDate"];
$pric = $r["SalePrice"];
$sch = $r["TaxAreaCode"];
$situ = $r["Situs"];
$tship = $r["Township"];
$rng = $r["Range"];
$sct = $r["Section"];
$inum = $r["InstrumentNumber"];
echo "<tr>
<td>$act</td>
<td>$nme</td>
<td>$add</td>
<td>$city</td>
<td>$ste</td>
<td>$zip</td>
<td>$legal</td>
<td>$pid</td>
<td>$size</td>
<td>$type</td>
<td>$sqft</td>
<td>$built</td>
<td>$valu</td>
<td>$impr</td>
<td>$iyr</td>
<td>$isze</td>
<td>$ivlu</td>
<td>$cost</td>
<td>$bldg</td>
<td>$date</td>
<td>$pric</td>
<td>$sch</td>
<td>$situ</td>
<td>$tship</td>
<td>$rng</td>
<td>$sct</td>
<td>$inum</td>
</tr>";
} // end while

echo "</table>";


You can see what I'm talking about at: . An example you can search by "730000008."

Now, I know when you search this account number, there are 4 or 5 different results that aren't duplicates. But, then those 4 or 5 results are there like 15 times or more. Why is it doing this???

Please help!

Thanks!
Qadoshyah

mlseim
02-01-2010, 11:06 PM
......


EDIT again ...


It was not doing this before!

before what?

Len Whistler
02-01-2010, 11:41 PM
I don't see the closing bracket for the if statement, I assume it might be after </table>. I would use an external CSS file to style the table and table rows instead of:

<td align=center bgcolor=#4A6B3F>Address</td>

Add some line breaks (\n) to clean up the browser source code, and change the while loop. Maybe something like:

Might be syntax errors.

if ($result) {

echo "Results:<br><br>";
echo "<table>\n"
echo "<th>Account</th><th>Owners Name</th><th>Address</th><th>City</th><th>State</th>
<th>Zip Code</th><th>Legal</th><th>Parcel ID</th><th>Property Size</th><th>Type</th>
<th>Total Sq. Ft</th><th>Est. Year Built</th><th>Total Value</th><th>Impr. Description</th>
<th>Impr. Year</th><th>Impr. Size</th><th>Impr. Value</th><th>Cost Value</th>
<th>Bldg. Description</th><th>Sale Date</th><th>Sale Price</th><th>School District</th>
<th>Situs</th><th>Township</th><th>Range</th><th>Section</th><th>Book & Page</th>\n";

while ($r = mysql_fetch_array($result)) {

echo "<tr><td>$r["Account"]</td><td>$r["OwnersName"]</td><td>$r["Address2"]</td><td>$r["City"]</td>
<td>$r["State"]</td><td>$r["LotSizeType"]</td><td>$r["LotSize"]</td><td>$r["Value"]</td>
<td>$r["SaleDate"</td><td> $r["SalePrice"]</td></tr>\n";

}

echo "</table>\n";

}



----------

CGDesigns
02-02-2010, 04:11 AM
Thanks! I will look into that.

I think it has something to do with the JOINs I've used at the moment. I'm going to give that a try, but I'm working on refining the search function on the site I'm working on first.

Qadoshyah



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum