/* Count function
$table Table Name
$counname Count Storage fields
$idname ID Field Name
The ID number that the $id queried
$view Save or view the number
Author: microrain
Home: Http://www.codechina.net
Email:web@codechina.net
*/
function counter ($table, $counname, $idname, $id, $view) {
Query the current number of views
$sql = "SELECT * from $table where $idname = $id";
$result =mysql_query ($sql);
$objresult =mysql_fetch_object ($result);
$count = $objresult $counname;
Update the database and reverse the current number of views as a result
$count 2= $count +1;
if ($view) {
$sql = "Update $table set $counname = $count 2 where $idname = $id";
mysql_query ($sql);
}
return $count 2;
}
?>
http://www.bkjia.com/PHPjc/532183.html www.bkjia.com true http://www.bkjia.com/PHPjc/532183.html techarticle /* Count function $table table name $counname count hold field $idname ID field name $id Query ID number $view Save or view Author: Microrain Home: http://www.codechina.net...< /c5>