need php counter

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Dominator69
Forum Newbie
Posts: 6
Joined: Tue Jul 22, 2003 10:02 pm

need php counter

Post by Dominator69 »

im looking for script like counter i want to have like top 10 songs i want to show it on the main page top 10 clicks on the songs so i need to know what kind of the script i have to look for thanx
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

If you create a views column (int), you can use this query (assuming you are using mysql) to increment views by 1each time an item is clicked on:

"UPDATE tablename SET views=views+1 WHERE aid='$aid'

To find the top ten, perform a LIMIT query and ORDER BY views.
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

LIMIT 0, 10


Every page add that you want counted

add a

Code: Select all

<?php
require ("counter.php");
?>
to it

(asuming your script is in counter.php)
Post Reply