Jump to content

Post counts


crazy/man

Recommended Posts

Hi all.

 

I have two forums reading same database.

 

Forum 1 works under prefix "f1_"

Forum 2 works under prefix "f2_"

 

Everything works normaln and both forums read same users but topics and posts are separated.

 

Now i want to, if it is somehow possible, in my post counter.. cout both prefixes if you know what i mean.

 

I want my counter read data from 2 tables and provide me a post count.

 

 

I am using this code right now and every forum has its own post count, but i want to make same post count for both forums.

 

	$dt=mysql_fetch_array(safe_query("SELECT count(postID) FROM ".f1_."forum_posts")) ;
	$posts=$dt[0];

 

 

So i want to make something like this: 

 

	$dt=mysql_fetch_array(safe_query("SELECT count(postID) FROM ".webs2_."forum_posts" + SELECT count(postID) FROM ".f2_."forum_posts")) ;
	$posts=$dt[0];

 

 

I hope you could understand my problem, sorry for my not so good English, i can hardly express myself.

Link to comment
https://forums.phpfreaks.com/topic/181204-post-counts/
Share on other sites

Something like:

 

      
$count1_query = "SELECT COUNT(*) AS count1_rows FROM table_name";
$count1_result  = mysql_query($count1_query) or die('View Count SQL Error, query failed<br>' . mysql_error());
$count1_row     = mysql_fetch_array($count1_result, MYSQL_ASSOC);
$count1 = $count1_row['count1_rows'];

$count2_query = "SELECT COUNT(*) AS count2_rows FROM table_name";
$count2_result  = mysql_query($count2_query) or die('View Count SQL Error, query failed<br>' . mysql_error());
$count2_row     = mysql_fetch_array($count2_result, MYSQL_ASSOC);
$count2 = $count2_row['count2_rows'];

$totalcounted = $count1+$count2;
echo $totalcounted;

 

im sure there is an easier way but this should in theory do the trick once edited to your needs

Link to comment
https://forums.phpfreaks.com/topic/181204-post-counts/#findComment-955973
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.