Jump to content

Outputing rows even if they dont match.


liquid79

Recommended Posts

The problem im having is it only displays the places it found results for not all of them even if they have results or not which i want it to do.

 

At the moment is displays:

 

place1  (2)

place2 (1)

 

Im trying to get it to display:

 

place1 (2)

place2(1)

place3(0)

place4(0)

place5(0)

 

My Code:

 

// Selects all the placenames where the district = district

$sql = mysql_query("SELECT * FROM places WHERE area = '$district' LIMIT 24");
while($row4 = mysql_fetch_object($sql)) {


//Counts districts where they = the get values ie.district, p_type and the placename from the above results

$sql2 = mysql_query("SELECT image_id, district, p_type, p_location, Active, COUNT(district) AS num FROM details_temp2 WHERE district = '$district' AND p_type  = '$p_type' AND p_location = '$row4->placename' AND Active ='1' GROUP BY district");
while($row5 = mysql_fetch_object($sql2)){


//  display a column with all the places names
echo'<tr>
    <td bgcolor="#a3cbfd" class="rollover"><a href="show_propertys.php?type=">'.$row4->placename.' </a></td>';

// display a column with how many results it found for each place
echo'
    <td bgcolor="#a3cbfd" class="rollover">('.$row5->num.')  </td>';

}
}

 

Hope this makes some sense! (just thought sorry if this is a mysql question.. im not sure if it is or not)

Link to comment
https://forums.phpfreaks.com/topic/81368-outputing-rows-even-if-they-dont-match/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.