php table for download 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
humpy
Forum Newbie
Posts: 5
Joined: Sat May 29, 2004 9:27 pm

php table for download counter

Post by humpy »

feyd | Please use

Code: Select all

tags when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


hey i have this download counter and there is a table in it for the stats, i was wondering if someone knew wut code i could use to make the table show the counter stats in order from highest to lowest downloads 

here is the code here

Code: Select all

} 
if($action=="show_stats"){ 
echo "<style>TD { FONT-SIZE: 12px; COLOR: #000000; FONT-FAMILY: Verdana }</style>"; 
echo "<FONT SIZE=3 COLOR=#000000 face=georgia><CENTER><B>Unique Downloads Counter</B></CENTER></FONT><BR>"; 
$handle = @opendir("download"); 
echo "<table cellspacing=0 align=center border=1 bordercolor=#000000 ><td align=center>Filename</td><td align=center>URL</td><td align=center>Count</td><td>Counting since</td>"; 
while (false !== ($file = readdir($handle))) { 
if ($file != "." && $file != ".." ) { 
$fn=fopen("download/".$file,"r"); 
$statis=file("download/".$file); 
$stat=explode("|", $statis[0]); 
fclose($fn); 
if($stat[2] != "0"){ 
echo "<tr><td>$stat[2]</td><td><a href='$stat[1]' target=_new>$stat[1]</a></td><td align=center>$stat[0]</td><td>$stat[4]</td></tr>"; 
} 
} 
} 
closedir($handle); 
echo "</table><hr color=#000000 width=50%>"; 
}

if you know wut i can put in to do that please let me know,
thanx humpy


feyd | Please use

Code: Select all

tags when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

Well if you want to do it with php, what you might be able to do is everytime someone clicks on that actual download link is make a db query and increment the number of downloads by 1
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

In Database:

Code: Select all

SELECT count FROM stats ORDER BY hits
From file:
Put in array and then do a sort on it.
Post Reply