Jump to content


Photo

I need a specific type of counter...


  • Please log in to reply
2 replies to this topic

#1 JoeMcClemont

JoeMcClemont
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 08 June 2006 - 05:34 PM

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?

#2 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 08 June 2006 - 05:40 PM

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.
~ D Kuang

#3 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 08 June 2006 - 05:44 PM

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:
select count(numhits) as total from table
or maybe even
$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;

edit: parrot beated me
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users