Recent Topics

Need help with word count hack

Started by on Feb 23, 2005 – Contents updated: Feb 23, 2005

Feb 23, 2005 06:07    

I'm not too sharp with the SQL/PHP stuff so I was hoping someone could help me.. All I would like to know is how could I add up the total number of words in all my posts and then request the result on a page? I'd like to do the same thing for the number of posts and total number of comments but if I can get help figuring out the first one, I could figure out the other two on my own.

Feb 23, 2005 13:45

<?php 

if( !defined('DB_USER') ) die( 'Please, do not access this page directly.' );

$query = "SELECT SUM(post_wordcount) FROM $tableposts";
$post_word_total = $DB->get_var($query);
$post_word_total = number_format($post_word_total); ?>
<li><?php echo $post_word_total.' words'; ?></li>

That'll do a word count with the commas for where commas go in numbers. Save it as _blah.php in your skins/skinname folder then put

<ul>
<?php require( dirname(__FILE__).'/_blah.php'); ?>
</ul>

in your _main.php where you want your total word count showing up.

Feb 24, 2005 11:42

Thanks guys, I appreciate the help.


Form is loading...

Open Source CMS – This forum is powered by b2evolution CMS, a complete engine for your website.