Jump to content
xisto Community
bx93

page counter with php+mysql Another solution for counter

Recommended Posts

Most counter were realized with files. Here I suggest another solution which use php and mysql.A file named welcome.php contains the following code:<?php function welcome(){ $query= "update webcount set count=count+1;"; mysql_query($query); $query= "SELECT count FROM webcount;"; $result = mysql_query($query); $row = mysql_fetch_row($result); return $row[0]; }?>in index.php file,require the welcome.php at the first place.<?phprequire("welcome.php");?><html>....</html>show the count:<?php echo welcome(); ?>There is some benefit we may get from this solution, though current version support only one counter in the system, but you could easily change it to multi-counter version which could used to count every page in the site or provide counter to the others.

Share this post


Link to post
Share on other sites

Not each provider gives a Free-Sql Account :), Isn't bettere to use a simple page with the number of the visitors?

<{POST_SNAPBACK}>


Yeah, there is really a little more complex if we want to provide others with MySql counter. When I designing the multi-version counter, I found that every time, there should be database connection and close task, which may not so fast than operations on files. What you mentioned maybe more important is that the counter provider should has the MySql access, thanks Xisto.com, but it is difficult to find when hosting at other place.

 

Anyway, I agree with your suggestion.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.