I'm working on a page where I plan on having "categories", with "articles" written under each category. This would be easy if there was only one level of articles... the problem is that I will end up having multiple levels of articles. For example, I may have this :
Geography
|-Countries
|- Cites
Economies
|-Country Economics
The problem lay with the nested articles.
My plan was to have the articles, when created, have the ID's of each category and article they were a part of, and IMPLODE them separated by commas - like so :
Categories
id Name
----------------------
1 Geography
2 Economies
Articles
id Name Category/Article ID
------------------------------------------
1 Countries 1,0
2 Cities 1,2
3 Country Economics 2,0
Then I could simply explode them after a query and list my articles under my categories.
However... the problem came when I started working on the SQL query to find which articles should go with the given category.
What I need to do is construct a query that will - using the example above - find the 1st number in the "Category/Article ID" field... something like this :
$sql = "SELECT * FROM articles WHERE category/articleID = '[1st number in field]'";
I don't know if this is possible... and frankly, I'm not even sure if this is the best method for creating this type of structure. I'd appreciate any help and suggestions as to how to resolve this.
Thanks.