Results 1 to 2 of 2

Thread: Duplicate values are echoed

  1. #1
    Join Date
    Oct 2017
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Duplicate values are echoed

    So I am getting data from my table and I used a while loop for it but there are duplicates being printed out. How to fix it?
    Here is my script/code:
    PHP Code:
    $dbmysqli_connect('localhost''root''''dbclientpetinfosys');
            
                if (
    $db->connect_error) {
                    die(
    "Connection failed: " $db->connect_error);
                }
                
                
    $quePetProfile "SELECT tblPet.strPetID, tblPet.strPetName, tblPet.strSpecies, tblPet.dbltAge, tblPet.strGender, tblBreed.strBreed
                                FROM tblPet
                                INNER JOIN tblBreed    
                                ON tblPet.strRegistrationID = tblBreed.strRegistrationID
                                LEFT JOIN abandoned
                                ON tblPet.strPetID = abandoned.strPetID
                                WHERE tblPet.strRegistrationID = '
    {$_SESSION['RegID']}' AND abandoned.strPetID IS NULL";
                            
    $stmtGetPet mysqli_query($db$quePetProfile);
                            while(
    $arrRow2 mysqli_fetch_array($stmtGetPet)){
                                            echo 
    '<tr>';
                        echo 
    '<td>'$arrRow2['strPetID'] .'</td>';
                        echo 
    '<td>' $arrRow2['strPetName'] . '</td>';
                        echo 
    '<td>' $arrRow2['strSpecies'] . '</td>';
                        echo 
    '<td>' $arrRow2['dbltAge'] . '</td>';
                        echo 
    '<td>' $arrRow2['strGender'] . '</td>';
                        echo 
    '<td>' $arrRow2['strBreed'] . '</td>';
                        echo 
    '</tr>';
                            } 
    Last edited by jscheuer1; 10-01-2017 at 12:46 PM. Reason: format code

  2. #2
    Join Date
    Mar 2010
    Location
    Florida
    Posts
    512
    Thanks
    9
    Thanked 61 Times in 59 Posts

    Default

    This is because of your left join. You most likely have multiple tblPet.strPetID = abandoended.strPetID.
    -DW [Deadweight]
    Resolving your thread: First Post: => EDIT => Lower right: => GO ADVANCED => Top Advance Editor drop down: => PREFIX:Resolved

Similar Threads

  1. Duplicate a Div
    By Clayf700 in forum JavaScript
    Replies: 1
    Last Post: 12-11-2010, 06:57 AM
  2. SEO duplicate content?
    By lowmarklow in forum Other
    Replies: 2
    Last Post: 08-19-2010, 02:36 AM
  3. Replies: 0
    Last Post: 12-12-2008, 08:45 PM
  4. Replies: 1
    Last Post: 07-14-2008, 11:57 PM
  5. Replies: 3
    Last Post: 05-27-2008, 05:36 PM

Bookmarks

Posting Permissions

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