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 } } ?> Quote Link to comment Share on other sites More sharing options...
Barand Posted November 29, 2008 Share Posted November 29, 2008 sort the array Quote Link to comment 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]); ?> Quote Link to comment Share on other sites More sharing options...
blueman378 Posted December 10, 2008 Share Posted December 10, 2008 opps Quote Link to comment 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 />"; } Quote Link to comment 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> Quote Link to comment 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? Quote Link to comment 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 Quote Link to comment 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> Quote Link to comment 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 Quote Link to comment 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.. Quote Link to comment 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, 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.