This is the more advanced sequel to an earlier question.
Here’s a link to an SQLFiddle to make things a bit clearer
I need to return something like (for each location):
Ground Floor
---------------
Garage
– Radiator
Kitchen
– Cooker
– Fridge
There’s going to be even more levels than this but if I can get started I should hopefully be able to go further as needed.
Thanks
Since SQL cannot return nested records as you have formatted above, you need only to return a query which orders your rows by floor then by sub_location. You’ll get both the
locationandsub_locationrepeated for each row, but in your application code loop when printing the results, you format them as you have above.When looping over your rowset in your application, you then only print the new location or sub_location when it changes. Formatting is done in code.
Assuming your rows are all in the array
$rowset: