I made a simple template system. I'm in the process of making a forum-style script, that has categories within categories. I would like to call my static template file that will display all of the data. I can do this easily enough for one query, but I can't get it ordered with the category-within-category system.
That was probably jibberish, let me try to articulate:
My query is set up in this fashion:
PHP Code:
$sql = mysql_query ("SELECT * FROM categories"); while ($row = mysql_fetch_array ($sql)) { echo $row['title'].'<br />';
$sql2 = mysql_query ("SELECT * FROM categories2 WHERE cat_id='".$row['id']."'"); while ($row2 = mysql_fetch_array ($sql2)) { echo $row2['title'].'<br />'; } }
Excuse the sloppy, that's just for an example. Now, that is how I want it to work. It displays the first category, then the sub-categories beneath, then the next main category...etc. Well, if I assign variables to these arrays and just pass them to my template, it displays, obviously, the main templates all in a list then all the sub categories under.
That still doesn't make any sense reading it, hopefully somebody knows what I want to do. I just need to retain the order in the above code through a static template file. Maybe by using variables to start/end loops, but I don't know how to do that.
Thanks!
|