Re: Count
| From: | Miles Thompson | Date: | Wed, 16 Jan 2002 20:42:02 +0000 |
| Subject: | Re: Count | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-15893@lists.php.net to get a copy of this message | ||
Barry,
Before leaping to the wrong conclusion, what exactly do you want to count? You can derive the number of times a page has been fetched from your web logs.
Alternately, you could add a table to your database, and at the top of the page the link points to, after you've established your database connection, etc.:
$sql_count = "update page_count set views = views + 1 where page = '$PHP_SELF' ";
mysql_query( $sql_count );
You'll have to add a record for each page to the database, and by now you know how to create tables etc. Justwatch out for reserved words and function names; when I first typed the query I used "count" in place of page_count. "Views" and "page" probably aren't such a hot choices either.
Fetching the counts for the pages involves nothing more than issuing "select * from page_count" and you'll have a per page count of all the clicks to each page.
Miles
At 08:07 AM 1/17/2002 +1300, Barry Rumsey wrote:
How do you add a count feature to a link. I can get stuff from the db but want to know how many times it's been read or click on?