perficut Posted June 21, 2008 Share Posted June 21, 2008 I would like to create a .php file that will look in the current diectory for any images and then display them in a 200x200 format. Layout can be simple, perhaps 4 or 5 pictures per row, and how ever many rowes are needed based on the number of pictures. The images will be named starting at 1.jpg up to an undetermined number. In some cases as many as 20 images. But each project we do will dictate the number of pictures uploaded. What I want to be able to do, is simply, delete all .jpg files in the directory, then upload all the new ones, everytime we work a new project. The php file will do the rest. The only images in the directory will be those for the project under way. When we finish the project the image files will remain, until a new project begins. Can anyone get me started on the code for this .php file? Quote Link to comment Share on other sites More sharing options...
DarkWater Posted June 21, 2008 Share Posted June 21, 2008 Just to let you know, we will not code this for you. Now that we're past that, you can use glob() to look for the files. Will they always be .jpg, because that would make it easy. xD Something like: $count = 0; foreach (glob("*.jpg") as $pic) { printf('<img src="%s" width="200" height="200" />', $pic); $count++; if ($count % 5 == 0) { echo "<br />"; } } Quote Link to comment Share on other sites More sharing options...
perficut Posted June 21, 2008 Author Share Posted June 21, 2008 Darkwater; 1. Yes they will always be .jpg files. 2. I wouldnt expect anyone to code the file, just get me started. 3. I'm new to php, have some old pascal, basic, c++ coding from a long time ago, so understanding code is not difficult for me. However, its been a long time, and of course I am trying to teach myself. What ou have provided is a great start. I will try to work with that and see what I can come up with. If anyone else has any tips, please feel free. Thank you! everyone. This is an invaluable forum and you guys have always helped me when I needed it. I only wish I could repay the favors. Quote Link to comment Share on other sites More sharing options...
DarkWater Posted June 21, 2008 Share Posted June 21, 2008 Actually, I think that code on it own will do the trick for you. =P Just put it in the folder where the images are. If you want it to be in a different folder, tell me. Quote Link to comment Share on other sites More sharing options...
dannyb785 Posted June 21, 2008 Share Posted June 21, 2008 You could also record images uploaded in a database. Then just do a mysql query for all images(or just the ones you want) and then $n = 0; while($row = mysql_fetch_assoc($result)) { extract($row); echo "<img src=$image_file_location height=200 width=200>"; $n++; if($n == 5) { echo "<br>\n"; $n = 0; } } something like that Quote Link to comment Share on other sites More sharing options...
DarkWater Posted June 21, 2008 Share Posted June 21, 2008 Except when echoing it, you need the img src in " ", which is why I used printf(). Also, I think he just wants to upload them all and have them appear. Quote Link to comment Share on other sites More sharing options...
dannyb785 Posted June 22, 2008 Share Posted June 22, 2008 Except when echoing it, you need the img src in " ", which is why I used printf(). Also, I think he just wants to upload them all and have them appear. Or you could just escape the quotes within the echo. Not really a big deal. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.