Query Results not returning correctly

I have a website with a MySQL database which users can search against that uses PHP.

I’m just a beginner and supporting this after an IT colleague developed it originally, but unfortunately don’t have access to ask for their help any more.

The issue is that on selecting some of the search criteria via the site some of the results are not being returned correctly. The majority are working and returning the results as expected, however there are 2 specifically which don’t (NCCD Results and IGS Results). Selecting values to search against in these 2 fields does return results but they don’t match up with the records of the value searched against.

I’ve included the whole page of code below as not sure which bit is most appropriate.

Any help would be much appreciated.

Beagle Health Search

 

To begin your search please populate at least one of the following fields:

 
Name:
 
Owner:
Sex:
All <?php include_once("consts.php");
					$query = "SELECT Sex_ID, SexName ";
					$query = $query . "FROM Sex ";
					$query = $query . "ORDER BY SexName ASC ";

					$connect = mysqli_connect(HOST, USER, PASS, DATABASE) or die (DIE);
					$results = mysqli_query( $connect, $query);

					while ($sex = mysqli_fetch_array($results))
					{
					    extract($sex);
							
                ?>
            <option value="<?php echo $Sex_ID; ?>"><?php echo $SexName; ?></option>
            <?php
				    }                
           
                    mysqli_free_result($results);
					mysqli_close($connect);
                ?>
          </select>
        </div>
      </div></td>
  <td width="53" class="style1">&nbsp;</td>
  <td width="66" class="style1"><div align="left">Country:</div></td>
  <td width="178" class="style1"><div align="left">
    <select name="Country_ID" id="Country_ID">
      <option selected="selected" value="0">All</option>
      <?php
				    include_once("consts.php");

					$query = "SELECT Country_ID, CountryName ";
					$query = $query . "FROM Country ";
					$query = $query . "WHERE Active = true ";
					$query = $query . "ORDER BY DisplayOrder ASC, CountryName ASC ";

					$connect = mysqli_connect(HOST, USER, PASS, DATABASE) or die (DIE);
					$results = mysqli_query( $connect, $query);

					while ($country = mysqli_fetch_array($results))
					{
					    extract($country);
							
                ?>
      <option value="<?php echo $Country_ID; ?>"><?php echo $CountryName; ?></option>
      <?php
				    }                
           
					mysqli_free_result($results);
					mysqli_close($connect);
				?>
    </select>
  </div></td>
</tr>
<tr>
    <td class="style5"><div align="left">MLS Result:</div></td>
    <td height="35" class="style1">
      <div align="left">
            <select name="Result_ID" id="Result_ID" >
                <option value="0">All</option>

				<?php
				    include_once("consts.php");

					$query = "SELECT Result_ID, ResultName ";
					$query = $query . "FROM Result ";
					$query = $query . "WHERE Active = true ";
					$query = $query . "ORDER BY DisplayOrder ASC, ResultName ASC ";

					$connect = mysqli_connect(HOST, USER, PASS, DATABASE) or die (DIE);
					$results = mysqli_query( $connect, $query);

					while ($result = mysqli_fetch_array($results))
					{
					    extract($result);
							
                ?>
				    <option value="<?php echo $Result_ID; ?>"><?php echo $ResultName; ?></option>								
				<?php
				    }                
           
					mysqli_free_result($results);
					mysqli_close($connect);
				?>                      
            </select>
    </div></td>
  <td width="53" class="style1">&nbsp;</td>
  <td width="66" class="style1"><div align="left">Colour:</div></td>
  <td width="178" class="style1"><div align="left">
    <select name="Colour_ID" id="Colour_ID">
      <option value="0" selected="selected">All</option>
      <?php
				    include_once("consts.php");

					$query = "SELECT Colour_ID, ColourName ";
					$query = $query . "FROM Colour ";
					$query = $query . "WHERE Active = true ";
					$query = $query . "ORDER BY DisplayOrder ASC, ColourName ASC ";

					$connect = mysqli_connect(HOST, USER, PASS, DATABASE) or die (DIE);
					$results = mysqli_query( $connect, $query);

					while ($colour = mysqli_fetch_array($results))
					{
					    extract($colour);
							
                ?>
      <option value="<?php echo $Colour_ID; ?>"><?php echo $ColourName; ?></option>
      <?php
				    }                
           
					mysqli_free_result($results);
					mysqli_close($connect);
                ?>
    </select>
  </div></td>
</tr>
<tr>
  <td valign="middle" class="style5"><div align="left">FVII Result:</div></td>
  <td height="35" valign="middle" class="style1"><div align="left">
    <select name="FVIIResult_ID" id="FVIIResult_ID">
      <option value="0">All</option>
      <?php
				    include_once("consts.php");

					$query = "SELECT FVIIResult_ID, Description ";
					$query = $query . "FROM FVIIResult ";
					$query = $query . "WHERE Active = true ";
					$query = $query . "ORDER BY DisplayOrder ASC, Description ASC ";

					$connect = mysqli_connect(HOST, USER, PASS, DATABASE) or die (DIE);
					$results = mysqli_query( $connect, $query);

					while ($result = mysqli_fetch_array($results))
					{
					    extract($result);
							
                ?>
      <option value="<?php echo $FVIIResult_ID; ?>"><?php echo $Description; ?></option>
      <?php
				    }                
           
					mysqli_free_result($results);
					mysqli_close($connect);
				?>
    </select>
  </div></td>
  <td valign="bottom" class="style1">&nbsp;</td>
  <td valign="bottom" class="style1">&nbsp;</td>
  <td valign="bottom" class="style1">&nbsp;</td>
</tr>
<tr>
  <td valign="middle" class="style5">NCCD Result:</td>
  <td height="24" valign="middle" class="style1"><select name="NCCDResult_ID2" id="NCCDResult_ID2">
    <option value="0" selected="selected">All</option>
    <?php
				    include_once("consts.php");

					$query = "SELECT NCCDResult_ID, Description ";
					$query = $query . "FROM NCCDResult ";
					$query = $query . "WHERE Active = true ";
					$query = $query . "ORDER BY DisplayOrder ASC, Description ASC ";

					$connect = mysqli_connect(HOST, USER, PASS, DATABASE) or die (DIE);
					$results = mysqli_query( $connect, $query);

					while ($result = mysqli_fetch_array($results))
					{
					    extract($result);
							
                ?>
    <option value="<?php echo $NCCDResult_ID; ?>"><?php echo $Description; ?></option>
    <?php
				    }                
           
					mysqli_free_result($results);
					mysqli_close($connect);
				?>
  </select></td>
  <td valign="bottom" class="style1">&nbsp;</td>
  <td valign="bottom" class="style1">&nbsp;</td>
  <td valign="bottom" class="style1">&nbsp;</td>
</tr>
<tr>
  <td valign="middle" class="style5"><div align="left">IGS Result:</div></td>
  <td height="35" valign="middle" class="style1"><div align="left">
    <select name="NCCDResult_ID" id="NCCDResult_ID">
      <option value="0" selected="selected">All</option>
      <?php
				    include_once("consts.php");

					$query = "SELECT NCCDResult_ID, Description ";
					$query = $query . "FROM NCCDResult ";
					$query = $query . "WHERE Active = true ";
					$query = $query . "ORDER BY DisplayOrder ASC, Description ASC ";

					$connect = mysqli_connect(HOST, USER, PASS, DATABASE) or die (DIE);
					$results = mysqli_query( $connect, $query);

					while ($result = mysqli_fetch_array($results))
					{
					    extract($result);
							
                ?>
      <option value="<?php echo $NCCDResult_ID; ?>"><?php echo $Description; ?></option>
      <?php
				    }                
           
					mysqli_free_result($results);
					mysqli_close($connect);
				?>
    </select>
  </div></td>
  <td valign="bottom" class="style1">&nbsp;</td>
  <td valign="bottom" class="style1">&nbsp;</td>
  <td valign="bottom" class="style1">&nbsp;</td>
</tr>
<tr>
    <td height="35" colspan="5" valign="middle" class="style5"><div align="center">
      <input type="submit" name="Search2" id="Search" value="Search" />
    </div></td>
  </tr>

To view the entire list please leave the search fields empty and click the search button.

 

<?php include_once("consts.php");
	// Grab search criteria from POST0
	$DogName = $_POST["DogName"];
	$OwnerName = $_POST["OwnerName"];
	$Result_ID = $_POST["Result_ID"];
	$Colour_ID = $_POST["Colour_ID"];
	$Sex_ID = $_POST["Sex_ID"];
	$Country_ID = $_POST["Country_ID"];
	$FVIIResult_ID = $_POST["FVIIResult_ID"];
	$NCCDResult_ID = $_POST["NCCDResult_ID"];
	$Count = 1;

	//echo "Dog Name: " . $DogName;
	//echo "Owner Name: " . $OwnerName;
	//echo "Result: " . $Result_ID;
	//echo "Colour: " . $Colour_ID;
	//echo "Sex: " . $Sex_ID;
	//echo "Country_ID: " . $Country_ID;

	$query = "SELECT D.Dog_ID AS 'Dog_ID', D.Name AS 'Name', S.SexName AS 'Sex', C.ColourName AS 'Colour' , O.Name AS 'Owner', R.ResultName AS 'Result', N.Description AS 		        'NCCDResult' ";
	$query = $query . "FROM Dog D ";
	$query = $query . "INNER JOIN Owner O ON D.Dog_Owner_ID = O.Owner_ID ";
	$query = $query . "INNER JOIN Sex S ON D.Dog_Sex_ID = S.Sex_ID ";
	$query = $query . "INNER JOIN Colour C ON D.Dog_Colour_ID = C.Colour_ID ";
	$query = $query . "INNER JOIN Result R ON D.Dog_Result_ID = R.Result_ID ";
	$query = $query . "INNER JOIN NCCDResult N ON D.Dog_NCCDResult_ID = N.NCCDResult_ID ";
	$query = $query . "WHERE D.Name LIKE '%$DogName%' AND O.Name LIKE '%$OwnerName%' ";

	if ($Result_ID  > 0)
		$query = $query . "AND D.Dog_Result_ID = $Result_ID ";
		
	if ($FVIIResult_ID  > 0)
		$query = $query . "AND D.Dog_FVIIResult_ID = $FVIIResult_ID ";
		
	if ($NCCDResult_ID  > 0)
		$query = $query . "AND D.Dog_NCCDResult_ID = $NCCDResult_ID ";
	
	if ($Colour_ID > 0)
		$query = $query . "AND D.Dog_Colour_ID = $Colour_ID ";
	
	if ($Sex_ID > 0)
		$query = $query . "AND D.Dog_Sex_ID = $Sex_ID ";
	
	if ($Country_ID > 0)
		$query = $query . "AND O.Owner_Country_ID = $Country_ID ";
	
	$query = $query . "ORDER BY created desc , Name ASC, Sex ASC, Colour ASC, DOB DESC ";
	$query = $query . "LIMIT 0,25";

	//echo "<br> $query";

	$connect = mysqli_connect(HOST, USER, PASS, DATABASE) or die (DIE);
	$results = mysqli_query( $connect, $query);

	while ($dog = mysqli_fetch_array($results))
	{

	   if ( $Count == 1 )
	   {
	 	echo "<tr>".
             "<th colspan='5'><div align='center'>Details of the latest 25 entries added/amended on the database:</div></th></tr>".
    		 "<tr><th>Name</th>".
			 "<th width='155'>MLS Result</th>".
    		 "<th width='120'>NCCD Result</th>".        	 	 
    	     "<th width='80'></th>".
  			 "</tr>";
                  
		}
		$Count = $Count + 1;
		extract($dog);
?>
  			<tr>
    			<td align="left"><?php echo $Name; ?></td>
                <td align="left"><?php echo $Result; ?></td>
   			  <td align="left"><?php echo $NCCDResult; ?></td>        			
    			<td align="right" width='70'><a href="<?php echo "./dogdetails.php?Dog_ID=" . $Dog_ID; ?>">View Detail</a></td>
  			</tr>

<?php
	}
             
            if ( $Count == 1 )
               {

echo"

";
}
echo"";
	mysqli_free_result($results);
	mysqli_close($connect);
?>
</table>

Click on View Details for further information.

 

 

 

 

 

 

Your search found no results. Please enter a new search.
Displaying “;
echo $Count-1;
echo” Results

Hello Lynn,

I think I see the two problems and I think I can easily correct them for you. But I need a few answers.

  1. Is the NCCD and IGS codes and description the same? They are being pulled from the same fields in the database.

  2. If they are suppose to be different I need the you to list out all the columns in the dog table.

Hi,

Thanks for the reply and any help would be appreciated!

The NCCD and IGS codes and description do have the same values as below, however they should return independently (i.e. if someone selects NCCDResult as clear it should only bring dogs back who are NCCDResult clear regardless of their IGSResult, unless a user selects NCCD clear and IGS affected for instance in which case it would be based on both criteria).

There is a separate table for each as below and the value should be coming from the relevant one - hope that makes sense.

The columns in the NCCDResult table are as follows:

Display Order Description Active NCCDResult_ID
1 Clear 1 1
2 Genetically Clear 1 2
3 Carrier 1 3
4 Affected 1 4
5 Untested 1 5

The columns and values in the IGSResult table are as follows:

Display Order Description Active IGSResult_ID
1 Clear 1 1
2 Genetically Clear 1 2
3 Carrier 1 3
4 Affected 1 4
5 Untested 1 5

The columns in the dog table are as follows:

Colour
Created
DOB
Dog_Colour_ID
Dog_Dog_ID_DAM
Dog_Dog_ID_Sire
Dog_FVIIResult_ID
Dog_ID
Dog_IGSResult_ID
Dog_NCCDResult_ID
Dog_Owner_ID
Dog_Result_ID
Dog_Sex_ID
Name
Result
Sex
Title

Thanks again and any help would be much appreciated!

If you need anything further with this to help just let me know!

Lynn

Sorry for taking so long to get back to you, I been busy all day today. You told me exactly what I needed to help you out.

I want you to compare what I did, to what you had before, so you can see the changes I made. Keep in mind I’m making these changes in the editor on this website, so It’s possible I missed typed something or have a syntax error, but hopefully not.

I added an extra column to display the IGS Results, I didn’t see one. So if the alignment is off that’s why (It’s hard to code something without being able to test it and I didn’t feel like mocking up test data.

If the queries are not pulling back the information you want - I think the issue might be with the data in the DOG table where maybe the NCCDResult_ID and IGSResult_ID might not be populated correctly.

[php]

Beagle Health Search

 

To begin your search please populate at least one of the following fields:

 
Name:
 
Owner:
Sex:
All <?php include_once("consts.php");
              $query = "SELECT Sex_ID, SexName ";
              $query = $query . "FROM Sex ";
              $query = $query . "ORDER BY SexName ASC ";

              $connect = mysqli_connect(HOST, USER, PASS, DATABASE) or die (DIE);
              $results = mysqli_query( $connect, $query);

              while ($sex = mysqli_fetch_array($results))
              {
                  extract($sex);
                    
                ?>
            <option value="<?php echo $Sex_ID; ?>"><?php echo $SexName; ?></option>
            <?php
               }                
           
                    mysqli_free_result($results);
              mysqli_close($connect);
                ?>
          </select>
        </div>
      </div></td>
  <td width="53" class="style1">&nbsp;</td>
  <td width="66" class="style1"><div align="left">Country:</div></td>
  <td width="178" class="style1"><div align="left">
    <select name="Country_ID" id="Country_ID">
      <option selected="selected" value="0">All</option>
      <?php
               include_once("consts.php");

              $query = "SELECT Country_ID, CountryName ";
              $query = $query . "FROM Country ";
              $query = $query . "WHERE Active = true ";
              $query = $query . "ORDER BY DisplayOrder ASC, CountryName ASC ";

              $connect = mysqli_connect(HOST, USER, PASS, DATABASE) or die (DIE);
              $results = mysqli_query( $connect, $query);

              while ($country = mysqli_fetch_array($results))
              {
                  extract($country);
                    
                ?>
      <option value="<?php echo $Country_ID; ?>"><?php echo $CountryName; ?></option>
      <?php
               }                
           
              mysqli_free_result($results);
              mysqli_close($connect);
           ?>
    </select>
  </div></td>
</tr>
<tr>
   <td class="style5"><div align="left">MLS Result:</div></td>
    <td height="35" class="style1">
      <div align="left">
            <select name="Result_ID" id="Result_ID" >
                <option value="0">All</option>

           <?php
               include_once("consts.php");

              $query = "SELECT Result_ID, ResultName ";
              $query = $query . "FROM Result ";
              $query = $query . "WHERE Active = true ";
              $query = $query . "ORDER BY DisplayOrder ASC, ResultName ASC ";

              $connect = mysqli_connect(HOST, USER, PASS, DATABASE) or die (DIE);
              $results = mysqli_query( $connect, $query);

              while ($result = mysqli_fetch_array($results))
              {
                  extract($result);
                    
                ?>
               <option value="<?php echo $Result_ID; ?>"><?php echo $ResultName; ?></option>                        
           <?php
               }                
           
              mysqli_free_result($results);
              mysqli_close($connect);
           ?>                      
            </select>
    </div></td>
  <td width="53" class="style1">&nbsp;</td>
  <td width="66" class="style1"><div align="left">Colour:</div></td>
  <td width="178" class="style1"><div align="left">
    <select name="Colour_ID" id="Colour_ID">
      <option value="0" selected="selected">All</option>
      <?php
               include_once("consts.php");

              $query = "SELECT Colour_ID, ColourName ";
              $query = $query . "FROM Colour ";
              $query = $query . "WHERE Active = true ";
              $query = $query . "ORDER BY DisplayOrder ASC, ColourName ASC ";

              $connect = mysqli_connect(HOST, USER, PASS, DATABASE) or die (DIE);
              $results = mysqli_query( $connect, $query);

              while ($colour = mysqli_fetch_array($results))
              {
                  extract($colour);
                    
                ?>
      <option value="<?php echo $Colour_ID; ?>"><?php echo $ColourName; ?></option>
      <?php
               }                
           
              mysqli_free_result($results);
              mysqli_close($connect);
                ?>
    </select>
  </div></td>
</tr>
<tr>
  <td valign="middle" class="style5"><div align="left">FVII Result:</div></td>
  <td height="35" valign="middle" class="style1"><div align="left">
    <select name="FVIIResult_ID" id="FVIIResult_ID">
      <option value="0">All</option>
      <?php
               include_once("consts.php");

              $query = "SELECT FVIIResult_ID, Description ";
              $query = $query . "FROM FVIIResult ";
              $query = $query . "WHERE Active = true ";
              $query = $query . "ORDER BY DisplayOrder ASC, Description ASC ";

              $connect = mysqli_connect(HOST, USER, PASS, DATABASE) or die (DIE);
              $results = mysqli_query( $connect, $query);

              while ($result = mysqli_fetch_array($results))
              {
                  extract($result);
                    
                ?>
      <option value="<?php echo $FVIIResult_ID; ?>"><?php echo $Description; ?></option>
      <?php
               }                
           
              mysqli_free_result($results);
              mysqli_close($connect);
           ?>
    </select>
  </div></td>
  <td valign="bottom" class="style1">&nbsp;</td>
  <td valign="bottom" class="style1">&nbsp;</td>
  <td valign="bottom" class="style1">&nbsp;</td>
</tr>
<tr>
  <td valign="middle" class="style5">NCCD Result:</td>
  <td height="24" valign="middle" class="style1"><select name="NCCDResult_ID2" id="NCCDResult_ID2">
    <option value="0" selected="selected">All</option>
    <?php
               include_once("consts.php");

              $query = "SELECT NCCDResult_ID, Description ";
              $query = $query . "FROM NCCDResult ";
              $query = $query . "WHERE Active = true ";
              $query = $query . "ORDER BY DisplayOrder ASC, Description ASC ";

              $connect = mysqli_connect(HOST, USER, PASS, DATABASE) or die (DIE);
              $results = mysqli_query( $connect, $query);

              while ($result = mysqli_fetch_array($results))
              {
                  extract($result);
                    
                ?>
    <option value="<?php echo $NCCDResult_ID; ?>"><?php echo $Description; ?></option>
    <?php
               }                
           
              mysqli_free_result($results);
              mysqli_close($connect);
           ?>
  </select></td>
  <td valign="bottom" class="style1">&nbsp;</td>
  <td valign="bottom" class="style1">&nbsp;</td>
  <td valign="bottom" class="style1">&nbsp;</td>
</tr>
<tr>
  <td valign="middle" class="style5"><div align="left">IGS Result:</div></td>
  <td height="35" valign="middle" class="style1"><div align="left">
    <select name="IGSResult_ID" id="IGSResult_ID">
      <option value="0" selected="selected">All</option>
      <?php
               include_once("consts.php");

              $query = "SELECT IGSResult_ID, Description ";
              $query = $query . "FROM IGSResult ";
              $query = $query . "WHERE Active = true ";
              $query = $query . "ORDER BY DisplayOrder ASC, Description ASC ";

              $connect = mysqli_connect(HOST, USER, PASS, DATABASE) or die (DIE);
              $results = mysqli_query( $connect, $query);

              while ($result = mysqli_fetch_array($results))
              {
                  extract($result);
                    
                ?>
      <option value="<?php echo $IGSResult_ID; ?>"><?php echo $Description; ?></option>
      <?php
               }                
           
              mysqli_free_result($results);
              mysqli_close($connect);
           ?>
    </select>
  </div></td>
  <td valign="bottom" class="style1">&nbsp;</td>
  <td valign="bottom" class="style1">&nbsp;</td>
  <td valign="bottom" class="style1">&nbsp;</td>
</tr>
<tr>
   <td height="35" colspan="5" valign="middle" class="style5"><div align="center">
     <input type="submit" name="Search2" id="Search" value="Search" />
    </div></td>
  </tr>

To view the entire list please leave the search fields empty and click the search button.

 

<?php include_once("consts.php");
  // Grab search criteria from POST0
  $DogName = $_POST["DogName"];
  $OwnerName = $_POST["OwnerName"];
  $Result_ID = $_POST["Result_ID"];
  $Colour_ID = $_POST["Colour_ID"];
  $Sex_ID = $_POST["Sex_ID"];
  $Country_ID = $_POST["Country_ID"];
  $FVIIResult_ID = $_POST["FVIIResult_ID"];
  $NCCDResult_ID = $_POST["NCCDResult_ID"];
  $IGSResult_ID= $_POST["IGSResult_ID"];
  $Count = 1;

  //echo "Dog Name: " . $DogName;
  //echo "Owner Name: " . $OwnerName;
  //echo "Result: " . $Result_ID;
  //echo "Colour: " . $Colour_ID;
  //echo "Sex: " . $Sex_ID;
  //echo "Country_ID: " . $Country_ID;

  $query = "SELECT D.Dog_ID AS 'Dog_ID', D.Name AS 'Name', S.SexName AS 'Sex', C.ColourName AS 'Colour' , O.Name AS 'Owner', R.ResultName AS 'Result',I.Description AS  'IGSResult' , N.Description AS 'NCCDResult' ";
  $query = $query . "FROM Dog D ";
  $query = $query . "INNER JOIN Owner O ON D.Dog_Owner_ID = O.Owner_ID ";
  $query = $query . "INNER JOIN Sex S ON D.Dog_Sex_ID = S.Sex_ID ";
  $query = $query . "INNER JOIN Colour C ON D.Dog_Colour_ID = C.Colour_ID ";
  $query = $query . "INNER JOIN Result R ON D.Dog_Result_ID = R.Result_ID ";
  $query = $query . "INNER JOIN NCCDResult N ON D.Dog_NCCDResult_ID = N.NCCDResult_ID ";
  $query = $query . "INNER JOIN IGSResult I ON D.Dog_IGSResult _ID = I.IGSResult _ID ";
  $query = $query . "WHERE D.Name LIKE '%$DogName%' AND O.Name LIKE '%$OwnerName%' ";

  if ($Result_ID  > 0)
     $query = $query . "AND D.Dog_Result_ID = $Result_ID ";
     
  if ($FVIIResult_ID  > 0)
     $query = $query . "AND D.Dog_FVIIResult_ID = $FVIIResult_ID ";
     
  if ($NCCDResult_ID  > 0)
     $query = $query . "AND D.Dog_NCCDResult_ID = $NCCDResult_ID ";

 if ($IGSResult_ID > 0)
     $query = $query . "AND D.Dog_IGSResult_ID = $IGSResult_ID ";
  
  if ($Colour_ID > 0)
     $query = $query . "AND D.Dog_Colour_ID = $Colour_ID ";
  
  if ($Sex_ID > 0)
     $query = $query . "AND D.Dog_Sex_ID = $Sex_ID ";
  
  if ($Country_ID > 0)
     $query = $query . "AND O.Owner_Country_ID = $Country_ID ";
  
  $query = $query . "ORDER BY created desc , Name ASC, Sex ASC, Colour ASC, DOB DESC ";
  $query = $query . "LIMIT 0,25";

  //echo "<br> $query";

  $connect = mysqli_connect(HOST, USER, PASS, DATABASE) or die (DIE);
  $results = mysqli_query( $connect, $query);

  while ($dog = mysqli_fetch_array($results))
  {

     if ( $Count == 1 )
     {
      echo "<tr>".
             "<th colspan='5'><div align='center'>Details of the latest 25 entries added/amended on the database:</div></th></tr>".
           "<tr><th>Name</th>".
         "<th width='155'>MLS Result</th>".
           "<th width='120'>NCCD Result</th>".                
           "<th width='120'>IGS Result</th>".                
            "<th width='80'></th>".
            "</tr>";
                  
     }
     $Count = $Count + 1;
     extract($dog);

?>







<?php } if ( $Count == 1 ) { echo""; } echo""; mysqli_free_result($results); mysqli_close($connect); ?>
</table>

Click on View Details for further information.

 

 

 

 

 

 

<?php echo $Name; ?> <?php echo $Result; ?> <?php echo $NCCDResult; ?> <?php echo $IGSResult; ?> <a href="<?php echo "./dogdetails.php?Dog_ID=" . $Dog_ID; ?>">View Detail
Your search found no results. Please enter a new search.
Displaying "; echo $Count-1; echo" Results
[/php]

Thank you for your reply and additional coding which I have tried, but the incorrect results are being returned.

I have had a look at the database and am unsure what you mean by the data in the DOG table not being populated correctly? Would you mind explaining a little more as this has me completely bamboozled :o

Just messing around with the searches on the website and have set one dog’s IGS result to ‘Clear’. Strangely when I select clear and search, all dogs on the database are returned apart from this one clear dog!

I feel like I may be missing one tiny thing which will slot everything in to place…

Have you changed the SQL query you are using? Could you post the updated query if you have?

If you can data dump your dog table for us, we can check to see if the data is linked correctly. Without knowing if the data is correct in the table, it’s hard to say that the results are coming back wrong.

Sponsor our Newsletter | Privacy Policy | Terms of Service