Page 1 of 1

Articles system

Posted: Fri May 06, 2011 2:11 pm
by Carbine
I'm creating an article system, with catergorys kind of like a forum. I've got sub forums so if you was to click a fourm, the subs will appear in there and it could go on for ever if I made enough sub forums :P But I want to count how many articles there is in the forum and in all the sub forums that belong to it.

Here's the link to take a look at what I mean, click the php section and you'll get what I mean:
http://www.comppchelp.com/articles.php

Re: Articles system

Posted: Fri May 06, 2011 2:13 pm
by jacek
if you can get a list of subforums you can use that in a query
SELECT COUNT(`id`) FROM `articles` WHERE `category` IN (1, 2, 3)
which should get the number of articles in the categories with ids 1, 2 and 3.

What is your database structure like ?

Re: Articles system

Posted: Fri May 06, 2011 2:16 pm
by Carbine
Can't be too sure as it's on my laptop and my new PC doens't have the webhost details nor database.

But I think:
(Catergories)
ID
Type(Not actually need atm)
Parent
Name
Place

(Articles)
ID
Parent
Title
UID
Date

Re: Articles system

Posted: Fri May 06, 2011 2:25 pm
by jacek
You need a way to get all of the child sections. Hmm.

You may have to not count the posts in sub sections, I don't think most forums do that anyway.

The only way to do it that I can think of would involve a lot of queries.

Re: Articles system

Posted: Fri May 06, 2011 2:27 pm
by jacek
http://dev.mysql.com/tech-resources/art ... -data.html

This may be of some use... no way to make it dynamic though :?

Re: Articles system

Posted: Fri May 06, 2011 6:30 pm
by Carbine
I'll just count the first sub catergories then, any after that doesn't matter :P

Re: Articles system

Posted: Fri May 06, 2011 6:35 pm
by jacek
Carbine wrote:I'll just count the first sub catergories then, any after that doesn't matter :P
okay ;)

I think you would be able to get the first X pretty easily hmm.