I am using this script for counting downloads which echos all the files with download counts in the folder "files":
$extension='';
$files_array = array();
$dir_handle = @opendir($directory) or die("There is an error with your file directory!");
while ($file = readdir($dir_handle))
{
if($file{0}=='.') continue;
$parts = explode('.',$file);
$extension = strtolower(end($parts));
if($extension == 'php') continue;
$files_array[]=$file;
}
sort($files_array,SORT_STRING);
$file_downloads=array();
$result = mysql_query("SELECT * FROM download_manager");
if(mysql_num_rows($result))
while($row=mysql_fetch_assoc($result))
{
$file_downloads[$row['filename']]=$row['downloads'];
}
The files are displayed on this way:
foreach($files_array as $key=>$val)
{
echo '<li><a href="download.php?file='.urlencode($val).'">'.$val.'
<span class="download-count" title="Times Downloaded">'.(int)$file_downloads[$val].'</span> <span class="download-label">download</span></a>
</li>';
}
How do i have to modify the script so that it does not echo the complete array but, lets say only: file1.zip, file2.zip and file3.zip?
Update Example of output how it is now: Left the filename, in the middle the counts of download and on the right the link to download. The foreach displays all the 8 files in the folder.
Files Count
a.zip 2 download
b.zip 1 download
c.zip 1 download
d.zip 0 download
e.zip 0 download
f.zip 0 download
g.zip 0 download
h.zip 0 download
Now i want to manually choose the files which should be displayed:
Files Count
a.zip 2 download
d.zip 1 download
g.zip 1 download
// skip the other files