Hi,
I’m hoping this is something quite basic. I’m trying to group values from a MySQL query into an array. I have a Wordpress set-up but I’m presuming this is more of a PHP rather than a Wordpress concern. I just want to know basically what is the best way of doing this. Essentially I currently have the following data:
Artist Name #1 - Event Date #1
Artist Name #2 - Event Date #2
Artist Name #1 - Event Date #3
Artist Name #1 - Event Date #4
And I want to find a way that I can group the Artist Names so that the data would output like this:
Artist Name #1
Event Date #1
Event Date #3
Event Date #4
Artist Name #2
Event Date #2
This is the code I have at the moment. How would I integrate an array and an extra Foreach loop to get the data organised like this. I’m still learning Arrays at the moment and would appreciate any assistance with this.
Okay, I’ve created an array now within the current foreach loop. How can I now echo this so that the outputted values are grouped by the artist name?? Here’s the array:
Hey K, it’s in a Wordpress installation. I’m using their get_posts function. If you have a look at the first post you’ll see how I’m pulling the data from the database.