Posts: 1,832
Location: Somewhere else entirely
|
For a start, you are not actually executing any queries here, just assigning a bunch of strings. Also, if all you want from the db is an average, you can do this directly in MySQL. You are calculating a whole bunch of different averages here, but if you take one of them and change this:
PHP Code:
$knowledgescores = "SELECT COUNT(*) as RecordCount, sum(knowledge) as sum from $table_name WHERE knowledge > 0"; if ($knowledgescores.recordcount > 0) { $TotalCount = $TotalCount + $knowledgescores.recordcount; $TotalSum = $TotalSum + $knowledgescores.sum; }
into this:
PHP Code:
$sql = "SELECT AVG(knowledge) as average from $table_name WHERE knowledge > 0"; $result = mysql_query($sql) or die(mysql_error()); $avg_knowledge = mysql_result($result,0,'average');
then that will get you your average for the knowledge category, and the other categories can be changed similarly.
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';
Please login or register to view this content. Registration is FREE (aka MSN handwriting for forums)
|