foreach problems
I am very new to PHP, so don't laugh at me if this problem is really easily solved....:confused:
Here is the code I have:
if ($action=="delete"){
$pics=directory("../gallery","JPG,jpg,JPEG,jpeg");
$pics=namefilter($pics,"tn_");
$pets=directory("../petfiles","pet");
// display list of pets with download links
foreach ($pets as $pet){
echo "<a href=\"javascript:loadOne();\">download</a> ";
echo $pet;
echo "<br />\n";
}
foreach ($pics as $pic){
echo "";
}
}
/*
Download pet file
*/
echo "<SCRIPT LANGUAGE=\"JavaScript\"><!--
function loadOne() {
window.location.href = '../petfiles/$pet';
setTimeout(\"window.location.href='index.php?delfile=$pic&action=delete&display=Delete+images'\",5000);
setTimeout(\"window.location.href='index.php?delfile=$pet&action=delete&display=Delete+images'\",5000);
}</SCRIPT>";
The idea is that when the user clicks the loadOne link for a pet, they get the pet file downloaded, then it is removed from the list. The removal works, it's just when you click a pet to download, it always provides the same pet file, even with more than one in the directory.
Can anyone help?
~Milli

