Record and display the number of articles in php. * Counting function $ table name $ counname: counting storage field $ idnameID field name $ id queried idnumber $ view save or view number author: microrain home page: www.codechina.net/* counting function
$ Table name
$ Counname count field
$ Idname ID field name
$ Id: id of the queried id
$ View save or view count
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 return the current browser count as the result
$ Count2 = $ count + 1;
If ($ view ){
$ SQL = "update $ table set $ counname = $ count2 where $ idname = $ id ";
Mysql_query ($ SQL );
}
Return $ count2;
}
?>
Tables $ table name $ counname count field $ idname ID field name $ id the queried idnumber $ view save or view number author: microrain home page: http://www.codechina.net...