Jump to content

Archived

This topic is now archived and is closed to further replies.

JoeMcClemont

I need a specific type of counter...

Recommended Posts

I need a counter on my website that counts SEPERATE pages and shows them on one. I have a main "videos" page and need it to say: viewed <COUNTERCODEHERE> times on each of the videos on my table, but all the counters I have used only count the actual page its on. Basically, I need a counter that counts other pages rather than the one its on. Does anyone know of any good ones?

Share this post


Link to post
Share on other sites
Just create a script that adds count for a page each time its executed. These must be stored in a database.

Then, retrieve the count(s) and display them on the other page.

Some people may suggest you to use MySQL as database, but if it's something small, you can use flatfiles, they work well too.

Share this post


Link to post
Share on other sites
counters use a database to store the count. all you really have to do is create an extra column in your table called page or something, which will hold the name of the webpage. then in your counter script, update the table where page = '$PHP_SELF' sort of thing. That way, your table will have x rows for x pages and each one is updated individually.

as far as the display part of your counter, you would select pretty much the same. examples:

overall count:
[code]
select count(numhits) as total from table
[/code]
or maybe even
[code]
$sql = "select * from table";
$rs = mysql_query($rs);
$total = 0;
while ($list = mysql_fetch_array($rs)) {
   $total += $list['numhits'];
   echo "hits on " . $list['page'] . ": " . $list['numhits'] . "<br>";
}
echo "total hits: " . $total;
[/code]

edit: parrot beated me

Share this post


Link to post
Share on other sites

×

Important Information

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.