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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.