wmguk Posted November 28, 2008 Share Posted November 28, 2008 Hi, This is a script i have to make thumbnails but it doesnt display them in any order... Can i make it find the lowest to highest? its in use in sever different folders of images... One folder has images like: KM-125-21-XXXX.jpg and other folders are simply XXXX.jpg Code on top of page: <?php $dir = $_GET['login']; $NBFile=0; $dir ="$dir"; if ($handle = opendir($dir)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { //if (substr($file, strlen($file)-3, 3)=="jpg" ) { $FileArray[] = $dir."/".$file; $NBFile=$NBFile+1; //} } } } closedir($handle); ?> Code in HTML <?php $NBPicswidth=1; $NBPics=0; for ($i=0; $i<$NBFile; $i++) { $Pic_Name1=$FileArray[$i]; ?><td class="image"> <a href="dis.php?image=<?php echo $Pic_Name1; ?>" target="order"><img src="<?php echo $Pic_Name1; ?>" height="150" border="0" align="top"></a> </td><?php $NBPics=$NBPics+1; if ( $NBPics==$NBPicswidth ) { $NBPics=0; ?> <?php } } ?> Link to comment https://forums.phpfreaks.com/topic/134683-solved-can-my-thumbnail-script-display-in-order-of-001-099/ Share on other sites More sharing options...
Barand Posted November 29, 2008 Share Posted November 29, 2008 sort the array Link to comment https://forums.phpfreaks.com/topic/134683-solved-can-my-thumbnail-script-display-in-order-of-001-099/#findComment-701396 Share on other sites More sharing options...
wmguk Posted December 10, 2008 Author Share Posted December 10, 2008 Hi, I tried several sort() codes, but none work.... can someone help please? <?php $NBPicswidth=1; $NBPics=0; for ($i=0; $i<$NBFile; $i++) { $Pic_Name2=$FileArray[$i]; $Pic_Name1= sort($Pic_Name2); ?> //I ALSO TRIED <?php $NBPicswidth=1; $NBPics=0; for ($i=0; $i<$NBFile; $i++) { $Pic_Name1=sort($FileArray[$i]); ?> Link to comment https://forums.phpfreaks.com/topic/134683-solved-can-my-thumbnail-script-display-in-order-of-001-099/#findComment-711183 Share on other sites More sharing options...
blueman378 Posted December 10, 2008 Share Posted December 10, 2008 opps Link to comment https://forums.phpfreaks.com/topic/134683-solved-can-my-thumbnail-script-display-in-order-of-001-099/#findComment-711282 Share on other sites More sharing options...
Barand Posted December 10, 2008 Share Posted December 10, 2008 $dir = $_GET['login']; $NBFile=0; $dir ="$dir"; if ($handle = opendir($dir)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { //if (substr($file, strlen($file)-3, 3)=="jpg" ) { [] = $dir."/".$file; $NBFile=$NBFile+1; //} } } } closedir($handle); sort ($FileArray); foreach ($FileArray as $filename) { echo "$filename <br />"; } Link to comment https://forums.phpfreaks.com/topic/134683-solved-can-my-thumbnail-script-display-in-order-of-001-099/#findComment-712015 Share on other sites More sharing options...
wmguk Posted March 3, 2009 Author Share Posted March 3, 2009 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <?php $dir = $_GET['login']; $NBFile=0; $dir ="$dir"; if ($handle = opendir($dir)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { //if (substr($file, strlen($file)-3, 3)=="jpg" ) { $FileArray[] = $dir."/".$file; $NBFile=$NBFile+1; //} } } } closedir($handle); ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> <style type="text/css"> <!-- body { margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; } .image{ border-style:outset; border-color: black; border-width:1px; } </style> </head> <body><table align="center"><tr> <?php $NBPicswidth=1; $NBPics=0; for ($i=0; $i<$NBFile; $i++) { $Pic_Name1=$FileArray[$i]; //$Pic_Name1= sort($Pic_Name2); ?> <td class="image"> <a href="dis.php?image=<?php echo $Pic_Name1; ?>" target="order"><img src="<?php echo $Pic_Name1; ?>" height="150" border="0" align="top"></a> </td> <?php $NBPics=$NBPics+1; if ( $NBPics==$NBPicswidth ) { $NBPics=0; } } ?> </table> </body> </html> Link to comment https://forums.phpfreaks.com/topic/134683-solved-can-my-thumbnail-script-display-in-order-of-001-099/#findComment-775314 Share on other sites More sharing options...
wmguk Posted March 3, 2009 Author Share Posted March 3, 2009 hey, thats my complete page, however when I used the script from Barand it failed to work... Any ideas? Link to comment https://forums.phpfreaks.com/topic/134683-solved-can-my-thumbnail-script-display-in-order-of-001-099/#findComment-775315 Share on other sites More sharing options...
blueman378 Posted March 3, 2009 Share Posted March 3, 2009 wow i think thats more annoying than just not using code tags, please just put the whole lot in a code block, anyway please be more specific what do you mean by it doesnt work Link to comment https://forums.phpfreaks.com/topic/134683-solved-can-my-thumbnail-script-display-in-order-of-001-099/#findComment-775375 Share on other sites More sharing options...
wmguk Posted March 3, 2009 Author Share Posted March 3, 2009 oh sorry, I didnt know how to write it for you... it just white screens... nothing appears at all <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <?php $dir = $_GET['login']; $NBFile=0; $dir ="$dir"; if ($handle = opendir($dir)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { //if (substr($file, strlen($file)-3, 3)=="jpg" ) { $FileArray[] = $dir."/".$file; $NBFile=$NBFile+1; //} } } } closedir($handle); ?><html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> <style type="text/css"> <!-- body { margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; } .image{ border-style:outset; border-color: black; border-width:1px; } </style> </head> <body><table align="center"><tr> <?php $NBPicswidth=1; $NBPics=0; for ($i=0; $i<$NBFile; $i++) { $Pic_Name1=$FileArray[$i]; //$Pic_Name1= sort($Pic_Name2); ?><td class="image"> <a href="dis.php?image=<?php echo $Pic_Name1; ?>" target="order"><img src="<?php echo $Pic_Name1; ?>" height="150" border="0" align="top"></a> </td><?php $NBPics=$NBPics+1; if ( $NBPics==$NBPicswidth ) { $NBPics=0; } } ?> </table> </body> </html> Link to comment https://forums.phpfreaks.com/topic/134683-solved-can-my-thumbnail-script-display-in-order-of-001-099/#findComment-775379 Share on other sites More sharing options...
blueman378 Posted March 4, 2009 Share Posted March 4, 2009 Have you got error reporting turned on? put ini_set('display_errors', 1); error_reporting(E_ALL); at the top of your page Link to comment https://forums.phpfreaks.com/topic/134683-solved-can-my-thumbnail-script-display-in-order-of-001-099/#findComment-776117 Share on other sites More sharing options...
wmguk Posted March 13, 2009 Author Share Posted March 13, 2009 hey, I now have a page simply saying: <?php ini_set('display_errors', 1); error_reporting(E_ALL); $dir = $_GET['login']; $NBFile=0; $dir ="$dir"; if ($handle = opendir($dir)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { [] = $dir."/".$file; $NBFile=$NBFile+1; } } } closedir($handle); sort ($FileArray); foreach ($FileArray as $filename) { echo "$filename <br />"; } ?> and its blank but if i view source i get: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=Content-Type content="text/html; charset=windows-1252"> <META content=UUAOAYIPOH name=SKYPE_FRAMEID></HEAD> <BODY></BODY></HTML> so still nothing makes sense.. Link to comment https://forums.phpfreaks.com/topic/134683-solved-can-my-thumbnail-script-display-in-order-of-001-099/#findComment-783688 Share on other sites More sharing options...
wmguk Posted March 13, 2009 Author Share Posted March 13, 2009 ugh... $FileArray was missing stupid mistake! thanks for all your help, Link to comment https://forums.phpfreaks.com/topic/134683-solved-can-my-thumbnail-script-display-in-order-of-001-099/#findComment-783692 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.