Skip to content
Advertisement

php echo each unique sql order by

From a db table I query all the results and order those by place. I echo this query into checkboxes. So every place has its own checkbox. Above all the checkboxes there is a title like select one or multiple places but now I would also like to add a title to each set of places.

I have the following column in a database:

JavaScript

I run this sql query:

JavaScript

Then I echo this:

JavaScript

This creates in total 8 checkboxes and looks a bit like this [] = checkbox

JavaScript

But how can I make it echo like this:

JavaScript

Advertisement

Answer

First group it for the first loop then get the plaats column of the group and create new query then add condition to it then create inner loop for group data, this code base on your data from your sqlfiddle

JavaScript

Which Return like this

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement