Page 1 of 1

php table for download counter

Posted: Sat Jul 17, 2004 9:53 pm
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]

Posted: Sun Jul 18, 2004 1:23 am
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

Posted: Sun Jul 18, 2004 4:41 am
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.