What I'm basically trying to do is make a little script that will get grab the word count for an article an display it.
I'm needing to get the article's ID and pass it to my database query. Could I create a function and call it like <?php echo word_count($_GET['id']); ?>
I've tried some different things, if someone could look and see how it should be...that would be great. Thanks in advance!
include 'setup.php';
// Make a MySQL Connection
mysql_connect($dbhost,$dbuser,$dbpasswd)or die("Connect Error: ".mysql_error());
@mysql_select_db($dbname) or die( "Unable to select database");
function word_count($id) {
// Retrieve all the data from the "example" table
$result = mysql_query("SELECT count_words FROM `article_words` WHERE `article_id` ='$id'")
or die(mysql_error());
// store the record of the table into $row
$row = mysql_fetch_array( $result );
// Print out the contents of the entry
echo "Count: ".$row['count_words'];
}