I'm in the process of converting a coldfusion application I wrote awhile ago into PHP. I've hit a wall trying to figure out how to group queries similar to coldfusions CFOUTPUT GROUP attribute (in case you're familiar with it).
Here is what I'm trying to do...
I have a query that outputs something similar to this
IMAGE_ID | IMAGE_TITLE | IMGPATH | IMGSIZE |
1 | myTitle | myFile_800.jpg | 800x600
1 | myTitle | myFile_1024.jpg | 1024x768
1 | myTitle | myFile_1280.jpg | 1280x1024
I need to group this by the ID and Title so it will basically return a structure like this
1 myTitle
--- myFile_800.jpg | 800x600
--- myFile_1024.jpg | 1024x768
--- myFile_1280.jpg | 1280x1024
2 myTitle
--- myFile_800 ... and so on
in coldfusion I could output this by using
<cfoutput query="myQuery" group="IMAGE_ID">
myID, myTitle
<cfoutput>
myFile, myImageSize
</cfoutput>
</cfoutput>
if anyone is familiar with how to do this in PHP could you please help? I thought of a very tedious way by looping through the results and setting multi-dimesnional arrays one after the other using some logic to determine how to group them but it just seems very messy, time-consuming, and I actually haven't gotten it to work just right yet (some of the arrays aren't getting set right)... I'm assuming there has to be an easier way to do this and it's just my inexperience with PHP that is the reason for the headache, if anyone can help point me in the right direction I would really appreciate it.