Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Feb 2010
    Thanked 0 Times in 0 Posts

    Returning duplicate results - why??

    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>
          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>
          } // 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!

    Last edited by WA; 07-14-2010 at 09:27 PM.

  • #2
    Master Coder
    Join Date
    Jun 2003
    Cottage Grove, Minnesota
    Thanked 1,096 Times in 1,087 Posts

    EDIT again ...

    It was not doing this before!
    before what?
    Last edited by mlseim; 02-01-2010 at 11:11 PM. Reason: I had the wrong answer.

  • #3
    Senior Coder Len Whistler's Avatar
    Join Date
    Jul 2002
    Vancouver, BC Canada
    Thanked 100 Times in 100 Posts
    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:
    PHP Code:
     <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.
    PHP Code:
    if ($result) {

    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)) {

    SaleDate"</td><td> $r["SalePrice"]</td></tr>\n";



    Last edited by Len Whistler; 02-01-2010 at 11:47 PM.
    Leonard Whistler

  • #4
    New Coder
    Join Date
    Feb 2010
    Thanked 0 Times in 0 Posts
    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.



    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts