I have an SQL database that lists businesses details and includes a columns for location and business category.
Lets say, in "Townsville" there are 9 businesses - 4 hotels, 3 shops, 2 bars and no garages.
So hotel 1 will have column "business category" = hotel, "location" = townsville, "name" = hotel 1
and hotel 2 will have "business category" = hotel, "location" = townsville, "name" = hotel 2
etc., etc.
I want to make a page that will list all of the businesses in Townsville and their details - no problem so far by using a SELECT query for that location - but I also want to make a list of all of the business types / categories that are listed for that area, without duplicating them. So I want a page that will say at the top:
Townsville has the following businesses listed:
Hotels
Shops
Bars
...without duplicating the categories because there is more than one business in each category.
Seems like I should be able to do this with an array_unique command, but I can't seem to make it work - I think because I am not building an array first that the command can deal with ) I get an error "...the argument should be an array..."
Please can someone explain how I should use this command correctly, including how to select / build the array from the database correctly. Or is there another way to do it?
Thanks!
Lets say, in "Townsville" there are 9 businesses - 4 hotels, 3 shops, 2 bars and no garages.
So hotel 1 will have column "business category" = hotel, "location" = townsville, "name" = hotel 1
and hotel 2 will have "business category" = hotel, "location" = townsville, "name" = hotel 2
etc., etc.
I want to make a page that will list all of the businesses in Townsville and their details - no problem so far by using a SELECT query for that location - but I also want to make a list of all of the business types / categories that are listed for that area, without duplicating them. So I want a page that will say at the top:
Townsville has the following businesses listed:
Hotels
Shops
Bars
...without duplicating the categories because there is more than one business in each category.
Seems like I should be able to do this with an array_unique command, but I can't seem to make it work - I think because I am not building an array first that the command can deal with ) I get an error "...the argument should be an array..."
Please can someone explain how I should use this command correctly, including how to select / build the array from the database correctly. Or is there another way to do it?
Thanks!