Database GROUP BY and Loops in PHP

admin

Administrator
Staff member
Here is my situation: I have a database of files that can be downloaded. Each file has a corresponding product, and each product has a category. Kind of like this:

[-]CATEGORY
| [-]PRODUCT
| [-]FILES
| [-]FILES
| [-]FILES
| [-]PRODUCT
| [-]FILES
| [-]FILES
| [-]FILES
[-]CATEGORY
| [-]PRODUCT
| [-]FILES
| [-]FILES
| [-]FILES
| [-]PRODUCT
| [-]FILES
| [-]FILES
| [-]FILES

My database query looks like this right now:
SELECT Files.ManuID, Files.FileID, Files.ModelID, Files.FileTitle, Files.FileDescription,
Files.FileURL, Files.FileStatusID,
FileStatus.FileStatusID, FileStatus.FileStatusID,
Manu.ManuID, Manu.ManuDescription,
Model.ModelID, Model.ModelDescription, Files.Date
FROM Files, FileStatus, Manu, Model
WHERE Files.FileStatusID = FileStatus.FileStatusID AND
Files.ManuID = Manu.ManuID AND
Files.ModelID = Model.ModelID
ORDER BY Manu.ManuDescription, Model.ModelDescription, Files.Date DESC

Is this query correct? And how can I loop this in PHP to output it like shown above? (Using <UL> and such)

I am completely lost on this...
 
Back
Top