katia Posted June 14, 2006 Share Posted June 14, 2006 I display some images after reading them from a folder, in a while.I sumbmit my form when clicking on an image file. In the new form, I need the file name and the file number in the new from. In my form they are displayed ok ,but since I write these information in a "while" when I submit the file picturenumber will have the last value of $dim, picture name the last value of $fname.Is there any way that I can store these variables so I submit the right values ? $opendir = opendir($album);$dim=0;while($fname=readdir($opendir)){ if (is_file($name)) { $dim++;echo "<td width=\"140\" align=middle >";echo "<input type=image src=$fname name=$fname title=\"$fname\" height=80 alt=\"$fname\" width=120 border=0 value=submit()>";echo "<input type=\"hidden\" name=\"picturenumber\" value=$dim>";echo "<input type=\"hiiden\" name=\"picturename\" value=$fname>";echo "</td>"; }//if} //while closedir($opendir); Link to comment Share on other sites More sharing options...
justsomeguy Posted June 14, 2006 Share Posted June 14, 2006 You need to make each image its own form. $opendir = opendir($album);$dim=0;while($fname=readdir($opendir)){ if (is_file($fname)) { $dim++; echo "<td width=\"140\" align=\"center\" >"; echo "<form action=\"submit.php\" method=\"post\" style=\"display: inline;\">"; echo "<input type=\"image\" src=\"{$fname}\" name=\"{$fname}\" title=\"{$fname}\" height=\"80\" alt=\"{$fname}\" width=\"120\" border=\"0\" value=\"submit()\">"; echo "<input type=\"hidden\" name=\"picturenumber\" value=\"{$dim}\">"; echo "<input type=\"hiiden\" name=\"picturename\" value=\"{$fname}\">"; echo "</form>"; echo "</td>"; }//if} //while closedir($opendir); Link to comment Share on other sites More sharing options...
justsomeguy Posted June 14, 2006 Share Posted June 14, 2006 You can also just make the images links instead of submit buttons. $opendir = opendir($album);$dim=0;while($fname=readdir($opendir)){ if (is_file($fname)) { $dim++; echo "<td width=\"140\" align=\"center\" >"; echo "<a href=\"submit.php?picturenumber={$dim}&picturename=" . urlencode($fname) . "\">"; echo "<img src=\"{$fname}\" name=\"{$fname}\" title=\"{$fname}\" height=\"80\" alt=\"{$fname}\" width=\"120\" border=\"0\">"; echo "</a>"; echo "</td>"; }//if} //while closedir($opendir); Link to comment Share on other sites More sharing options...
katia Posted June 14, 2006 Author Share Posted June 14, 2006 That worked for me. Thanks Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now