This is going to be difficult to explain clearly, but i'll try my best.
I have 3 tables in a database (i've made up rather stupid names for clarity's sake):
"foodtype", this has two fields: foodtype.id and foodtype.name
->for example: (1,vegetable) (2,meat)(3,fish)
"subtype", this has three fields: subtype.id , subtype.foodtype_id and subtype.name
->for example: (1,1,carrots) (2,1,broccoli)(3,2,steak)(4,3,trout)
"recipe", this has three fields: recipe.id, recipe.subtype_id and recipe.name
->for example: (1,3,bbq steak)(2,3,steak stew)(3,1,carrot mash)
So, the first is the parent of the second which is the parent of the third. Now, using the data above, what i want would be to create the following table:
[FONT=courier new]
|____vegetable_|meat|fish|
|carrots|broccoli|steak|trout|
|carrot mash|____|bbq steak||
|______|____|steak stew|______|
[/FONT]
(its a bit empty, but hopefully you get the idea) there are columns for foodtype, which are split into columns for subtype, and the recipes for each subtype are listed underneath.
Now, this would actually be quite easy if the table was rotated 90degrees, but this is giving me troubles. I can create the first two rows, i query the number of records in table subtype linked to a given foodtype, and make <td colspan="that number">. then for the next row i list the subtype.name, ORDER BY foodtype.id (requires a join, but not too hard).
Now at this stage i start banging my head against a wall, because HTML requires that you work in rows instead of columns, so i guess i need to make a query that i only get one record of each recipe.subtype_id, and then cycle though those - but i don't know how. remember the number of columns is dynamic as is the number of rows.
Well, I think its tricky anyway; can anyone wrap their head around the problem? I'd be incredibly grateful for any sort of help or even just ideas thrown out there to try.