I have a static front page that contains links to several blogs. To the right of the blog title on this front page I want to display the total number of posts and comments for each blog. What is the best way to get these totals?
Below is what I am thinking of at the moment, but may not be effiecient. Is there a better way? Other ideas?
@ $db = mysql_connect('localhost','username','password');
$qryblog21_posts = "select count(*) -1 as ct from wp01_posts";
$qryblog21_comments = "select count(*) -1 as ct from wp01_comments";
$result21_posts = mysql_query($qryblog21_posts);
$result21_comments = mysql_query($qryblog21_comments);
$array21_posts = mysql_fetch_array($result21_posts);
$array21_comments = mysql_fetch_array($result21_comments);
if ($array21_posts && $array21_comments)
Any suggestions welcome.
Thanks in advance.
- The topic ‘How to get counts of posts and comments?’ is closed to new replies.