2017-01-26, 04:46 PM
Hello everyone, first post here Not sure in which section to post, so I am leaving my question here.
I am working on a project, using the MyBB forum platform. I need certain information regarding the posts of the different forums (categories), such as total amount of posts (threads + replies) in the forum and total views of the posts. For the amount of posts per forum, I am using the code below.
My question is how to get the views data (to sum up all of the views from all the threads in the forum)? Can't see "view" field in any of the tables of the MyBB database.
It is a bit of a work around, so that I get the total amount of posts (threads + replies) from the current forum and all it's sub-forums. I know it's ugly written but it's working, but I would still accept if some of you has a better solution Don't judge me too hard, it is my first project with coding for the web.
I am working on a project, using the MyBB forum platform. I need certain information regarding the posts of the different forums (categories), such as total amount of posts (threads + replies) in the forum and total views of the posts. For the amount of posts per forum, I am using the code below.
My question is how to get the views data (to sum up all of the views from all the threads in the forum)? Can't see "view" field in any of the tables of the MyBB database.
$pid = 10; //pid of the forum of interest
$data1 = 0; //just variable for accumulating the amount of posts
//getting the posts from the forum
$query = $db->query("SELECT posts FROM mybb_forums WHERE fid='".$pid."'");
while($result = $db->fetch_array($query))
{
$post1 += $result['posts'];
}
//getting the posts from the sub-forums
$query = $db->query("SELECT posts FROM mybb_forums WHERE pid='".$pid."'");
while($result = $db->fetch_array($query))
{
$post1 += $result['posts'];
}
It is a bit of a work around, so that I get the total amount of posts (threads + replies) from the current forum and all it's sub-forums. I know it's ugly written but it's working, but I would still accept if some of you has a better solution Don't judge me too hard, it is my first project with coding for the web.