Red Squirrel
[H]F Junkie
- Joined
- Nov 29, 2009
- Messages
- 9,211
I need to query a topics table and get the number of posts per forum that match my criteria, in my case, the number of posts that are pending approval, and by a certain member.
So to get the number of new posts for forum ID 10 for example, I would go $forums[10]; and get the number of posts that matched my query, where forum_id was 10. Now in my while loop, is it safe to assume that the first time I refer to $forums[10] that the default value will be 0 so when I do my increment it will go to 1? This cannot be initialized ahead of time since I do not know what all the forum IDs are, it does not necessarily start from 1 to nnn as forums get deleted/added over time.
Code:
$DB->query("SELECT forum_id FROM ibf_topics WHERE starter_id=".$vuid." AND approved==0");
while($row = $DB->fetch_row())
{
$forums[$row['forum_id']+=1;
}
//foreach loop to get data and do stuff with it
So to get the number of new posts for forum ID 10 for example, I would go $forums[10]; and get the number of posts that matched my query, where forum_id was 10. Now in my while loop, is it safe to assume that the first time I refer to $forums[10] that the default value will be 0 so when I do my increment it will go to 1? This cannot be initialized ahead of time since I do not know what all the forum IDs are, it does not necessarily start from 1 to nnn as forums get deleted/added over time.