PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Smackie wrote:ok im back i figured out it but still not returning what i need its returning as both posts as 0 here is what i got now
Then you need to rethink your queries. They are supposed to make sense.
$get_num_topics... Is that query supposed to get a count of all of the topics? Then why are you counting the forumids where they all have a specific id? What would you think that could possibly do?
And $get_num_posts... That's supposed to give you a count of all posts to a question? Then why are you counting the question_ids where they all have a common a_id, which I assume is the answer's id?
Seriously... The syntax isn't gibberish. COUNT means count. Whatever you put into it will be counted. WHERE means where. Whatever conditions you put in it are the condition that must be met for a row to be counted.
ok i got the topics posting right which is good but the posts isn't working right so i was wondering could i join 2 tables together for this? or how should i do this so the posts count as well
Either you still don't understand what I said to you in my last post, or your table names make absolutely no sense.
Look at your queries...
"SELECT forumid FROM forum_question..."
"SELECT question_id FROM forum_answer..."
Sensibly, forum_question would be each topic, and the forumid of each topic would be the forum that they belong to. Why would $get_num_topics care about the amount of forumids in forum question? You use the same backwards logic in the second query.
SELECT means select. Whatever you put after it, it selects. FROM means from. Whatever you put after it is the table you select from. The reason your code isn't working is because you are writing it wrong.