当前位置:Gxlcms > PHP教程 > 文章阅读次数的记录与显示函数php_PHP教程

文章阅读次数的记录与显示函数php_PHP教程

时间:2021-07-01 10:21:17 帮助过:24人阅读

/*计数函数
$table 表名
$counname 计数存放字段
$idname ID字段名
$id 所查询的ID号
$view 保存还是查看数
作者:microrain
主页:http://www.codechina.net
Email:web@codechina.net
*/

function counter($table,$counname,$idname,$id,$view) {
//查询当前浏览数
$sql="select * from $table where $idname=$id";
$result=mysql_query($sql);
$objresult=mysql_fetch_object($result);
$count=$objresult->$counname;
//更新数据库,并反回当前浏览数作为结果
$count2=$count+1;
if($view){

$sql="update $table set $counname=$count2 where $idname=$id";
mysql_query($sql);
}
return $count2;
}
?>

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/532183.htmlTechArticle/*计数函数 $table 表名 $counname 计数存放字段 $idname ID字段名 $id 所查询的ID号 $view 保存还是查看数 作者:microrain 主页:http://www.codechina.net...

人气教程排行