The record and display function of article reading frequency php_php tutorial

Source: Internet
Author: User
/* 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>

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.