Link to home
Start Free TrialLog in
Avatar of Caldera_Mike
Caldera_MikeFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Displaying number of products in a category - MySQL Query

Hi,  I have a table in MySQL with properties in it with fields such as house.roadname & house.propertytype.

When a user searches my database for a road name, i'd like the query to group by house.propertytype and also state how many results per propertytype in brackets (so I assume it passes this value to a php variable?)  Lets say the user searches for Windsor Road, I'd like the results to look like this:

Windsor Road (Total 67 Properties)
     Detached House (18)
     Semi-detached House (38)
     Detached Bungalow (9)
     Semi-detached Bungalow (2)

Can someone enlighten me on the query as I'm no expert but the theory seems so simple!
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

you mean:
select propertytype, count(*)
  from yourtable
where roadname = 'abc'
group by propertytype


the rest is displaying the results...

Open in new window

Avatar of Caldera_Mike

ASKER

Hi, y but how do i pass the count result per propertytype to php to display it?  Thats the bit i'm stuck on.
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
cool, going to try this out now....
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.