Revision [1868]

This is an old revision of GmBowenCounter made by GmBowen on 2004-10-16 04:56:39.

 

Well, this script works "sort of"....the counter works just fine until the page is edited, and then it resets. I thought that I could find a place in edit.php to get the old counter value from and then when the page saved write that value to the new row in the pages table. Uh, but no luck. And I tried changing Loadpage and Savepage functions in wakka.php adding the $hits variable there, but without success (remember all, I'm not a programmer so have trouble sometimes figuring out someone else's code to add to it). So, if anyone who has a better understanding of wikka structure has any suggestions about where I'd do the work of reading the old count and writing the new one I'd appreciate the guidance. -- Mike


entry into _pages table....

`hits` int(50) NOT NULL default '0'

and the counter.php code....

<?
$thispage=$this->GetPageTag();
// Get hit count
$result2 = mysql_query( "SELECT hits FROM '.$this->config["table_prefix"].'pages WHERE tag='$thispage' AND latest='Y'" );
$row2 = mysql_fetch_array($result2); 
$hit_count1 = $row2[hits];
// End Get hit Count   Start adding hits
$hit_count2 = $hit_count1 + 1;
// End adding hits   Start Update Hit 
$sql = "UPDATE `$this->config["table_prefix"]pages` SET `hits` = '$hit_count2' WHERE tag='$thispage' AND latest='Y'";
// $sql .= " WHERE `ref` = $ref";
mysql_query($sql) or die("Unable to process query: " . mysql_error());
// End Update Hit

// End Do not edit

// Start output of counter
$result4 = mysql_query("SELECT hits FROM '.$this->config["table_prefix"].'pages WHERE tag='$thispage' AND latest='Y'");
$row4 = mysql_fetch_array($result4); 
$hit_count3 = $row4['hits'];
echo '<table cellpadding="0" cellspacing="0">';
echo '<tr><td><font face="verdana" size="2"><b>Total Hits:</b></font></td><td><font face="verdana" size="2">&nbsp;';
print "$hit_count3";
echo '</font></td></tr></table>';
// End Output of counter
?>

Valid XHTML :: Valid CSS: :: Powered by WikkaWiki