JoeMcClemont Posted June 8, 2006 Share Posted June 8, 2006 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? Quote Link to comment https://forums.phpfreaks.com/topic/11504-i-need-a-specific-type-of-counter/ Share on other sites More sharing options...
poirot Posted June 8, 2006 Share Posted June 8, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/11504-i-need-a-specific-type-of-counter/#findComment-43289 Share on other sites More sharing options...
.josh Posted June 8, 2006 Share Posted June 8, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/11504-i-need-a-specific-type-of-counter/#findComment-43290 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.