web_master Posted October 26, 2007 Share Posted October 26, 2007 hi, I have a pictures in one folder. Picture names is: 1_photo.jpg 2_photo.jpg 3_photo.jpg ... 100_photo.jpg ... and more is there some posibility to list (print on screen) pictures without dbase. Mean to do one cycle (while), and list this pictures all, or with some limits. thnx web_master Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted October 26, 2007 Share Posted October 26, 2007 if ($handle = opendir(DOCROOT . 'global/images/content')) { while (false !== ($file = readdir($handle))) { if ( $file != '.' && $file != '..' ) { echo $file . <br />; } } closedir($handle); } Quote Link to comment Share on other sites More sharing options...
web_master Posted October 27, 2007 Author Share Posted October 27, 2007 ok, its work, I see now, to want more this works perfectly, but... what can I do if I want to list only last 10 pictures? pictures have a id nrs: 1_photo_file.jpg 2_photo_file.jpg 3_photo_file.jpg ... etc ... but I want to list from 200_photo_file.jpg to 290_photo_file.jpg DESC. (mean: order DESC LIMIT 10) <?php if ($handle = opendir("up_photo/")) { while(false !== ($file = readdir($handle))) { if($file != "." && $file != "..") { $photoprint = "<img src=\"up_photo/".$file."\" alt=\"\" border=\"0\" width=\"130\"><br><br>\n"; if(stristr($file, "_th")){$photoprint = "";} print $photoprint; } } closedir($handle); } ?> Quote Link to comment Share on other sites More sharing options...
calabiyau Posted October 27, 2007 Share Posted October 27, 2007 if ($handle = opendir(DOCROOT . 'global/images/content')) { while (false !== ($file = readdir($handle))) { //explode the file name by the underscore and check the first element in the array //which will be your number at the beginning of the filename. //then in the conditional check, check to see if the number is in the range you want //of course this will only work if you standardaize your file names and make sure the //number is always first in the file name $numbers = explode('_',$file); if ( $file != '.' && $file != '..' && ($numbers[0]>200) && ($numbers[0]<290) ) { echo $file . <br />; } } closedir($handle); } Quote Link to comment Share on other sites More sharing options...
web_master Posted October 27, 2007 Author Share Posted October 27, 2007 thanx people, its work perfectly! its in a www.tanyaszinhaz.com ::: site is under construction, but on a right site You will see pictures listed with script. 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.