Home > Backend Development > PHP Tutorial > Recording and displaying functions of article reading times php_PHP tutorial

Recording and displaying functions of article reading times php_PHP tutorial

WBOY
Release: 2016-07-13 17:23:50
Original
1023 people have browsed it


/*Counting function
$table table name
$counname counting storage field
$idname ID field name
$id queried ID number
$view save or view the number
Author: microrain
Homepage: 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 return the current number of views as the result
$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/*Counting function $table table name $counname counting storage field $idname ID field name $id queried ID No. $view Save or view the number Author: microrain Home page: http://www.codechina.net...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template