Ok, i have this script that I'm making that:
lets the admin select a number of images that are fetched from a directory, select a few with checkboxes, and then it writes the file names of each image selected in a text file.
I have most of it down, except for the part with the check boxes and writing the file name.
This is what i have here:
Here is the main page that displays the images.
<?php
$imagefolder = "pics";
$times = "0";
echo $imagefolder ."<br>" ;
//starts the form
print '<form action="adding.php" method="post">';
print '<table border="1" cellpadding="0" cellspacing="0" width="75%">';
print '<br>';
$couponnumber = "1";
//the mighty loop begins
$dir = opendir($imagefolder);
while($file = readdir($dir))
{
if(($file=='.')||($file=='..')) continue;
//limits the table to two cells
$times = $times + 1;
if ( $times > 2) {
$times = "1";
print '<tr>';
} else {
print "";
}
//end of table limit
print '<td width="100%">';
print '<br>';
//displays picture with link to file
echo "<a href=\"$imagefolder/$file\"><img src=\"$imagefolder/$file\" width=\"300\" height=\"130\" border=\"0\"></a>";
print '<br>';
//makes link to file
echo "<a href=\"$imagefolder/$file\">$file</a>";
print '<br>';
print '<p>Add? <input type="checkbox" name="coupon"$couponnumber"" value=""$file""></p>';
$couponnumber = $couponnumber + 1;
print '</td>';
}
//End of the mighty loop
print '</table>';
print '<p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>';
closedir($dir);
?>
Its kind of a dirty code, but it works, now for the part with the problem....
adding.php (the page which the form on the previous page submits to)
<?php
//count number of files in the pic directory
$gallery = opendir(pics);
$number = 0;
while($file = readdir($gallery)){
if($file != '.' && $file != '..'){
$number++;
}
}
closedir($gallery);
echo($number);
//end count number of files
//assigning the value of each checkbox to a variable, each kupon with a number after it.
while ($loops <= $number){
$ku_pon"$loops" = $_REQUEST["coupon"$loops""];
$loops = $loops + 1;
}
//just testing to see if it works
print "$ku_pon1";
print "<br>";
?>
The error that im getting is on the
"$ku_pon"$loops" = $_REQUEST["coupon"$loops""];"
line.
If you want to see a example of what this looks like at the moment, check out:
http://www.visionsfromthepalantiri.com/pizza/cp/test.php
I havnt done the part where it writes the filename to the text file because first i want to get this working.
Its going to be used for a pizza site i'm doing for free, , but I'm testing it out on this that lord of the rings site 🙂
Any suggestions?
Thanks.
Jason