phpretard Posted April 16, 2008 Share Posted April 16, 2008 Can someone help me turn this code into pictures? galleryarray[0]=["P1120081.jpg"]; galleryarray[1]=["P1120082.jpg"]; galleryarray[2]=["P1120083.jpg"]; galleryarray[3]=["P1120084.jpg"]; galleryarray[4]=["P1120085.jpg"]; galleryarray[5]=["P1120086.jpg"]; Link to comment https://forums.phpfreaks.com/topic/101416-solved-stinkin-pictures/ Share on other sites More sharing options...
conker87 Posted April 16, 2008 Share Posted April 16, 2008 Don't quote me on this, I've not looked into for each much, but i suspect it should work. for each ($galleryarray[] as $ga) { echo "<img src=\"<?php echo $ga; ?>\" />"; } Link to comment https://forums.phpfreaks.com/topic/101416-solved-stinkin-pictures/#findComment-518710 Share on other sites More sharing options...
jonsjava Posted April 16, 2008 Share Posted April 16, 2008 full code (working): <?php $galleryarray = array(); $galleryarray[0]="P1120081.jpg"; $galleryarray[1]="P1120082.jpg"; $galleryarray[2]="P1120083.jpg"; $galleryarray[3]="P1120084.jpg"; $galleryarray[4]="P1120085.jpg"; $galleryarray[5]="P1120086.jpg"; foreach ($galleryarray as $ga) { echo "<img src='".$ga.">\n"; } ?> Link to comment https://forums.phpfreaks.com/topic/101416-solved-stinkin-pictures/#findComment-518731 Share on other sites More sharing options...
phpretard Posted April 16, 2008 Author Share Posted April 16, 2008 I appologize for not showing the rest of the script. Here it is. while($row = mysql_fetch_array($result)) { $lastname=$row['lastname']; $firstname=$row['firstname']; echo $firstname ." ". $lastname; } function returnimages($dirname="ALBUMS/$lastname") { $pattern="\.(jpg|jpeg|png|gif|bmp)$"; $files = array(); $curimage=0; if($handle = opendir($dirname)) { while(false !== ($file = readdir($handle))){ if(eregi($pattern, $file)){ echo '<br>galleryarray[' . $curimage .']=["' . $file . '"];' . "<br>"; $curimage++; } } closedir($handle); } return($files); } returnimages(); Where should I put the code you provided? Link to comment https://forums.phpfreaks.com/topic/101416-solved-stinkin-pictures/#findComment-518738 Share on other sites More sharing options...
phpretard Posted April 16, 2008 Author Share Posted April 16, 2008 Now there's problem with this?? function returnimages($dirname="ALBUMS/$lastname") Link to comment https://forums.phpfreaks.com/topic/101416-solved-stinkin-pictures/#findComment-518750 Share on other sites More sharing options...
jonsjava Posted April 16, 2008 Share Posted April 16, 2008 function returnimages($dirname="ALBUMS/$lastname") should be: $dirname = "ALBUMS/".$lastname; function returnimages($dirname) Link to comment https://forums.phpfreaks.com/topic/101416-solved-stinkin-pictures/#findComment-518771 Share on other sites More sharing options...
phpretard Posted April 16, 2008 Author Share Posted April 16, 2008 $dirname = "ALBUMS/".$lastname; function returnimages($dirname) Somehow it produced this: Warning: Missing argument 1 for returnimages(), called in /home/content/r/e/m/rememberthe/html/pages/photos_get.php on line 47 and defined in /home/content/r/e/m/rememberthe/html/pages/photos_get.php on line 17 I did get the pictures to finaly display...now the only problem is defining the path with the code above. Link to comment https://forums.phpfreaks.com/topic/101416-solved-stinkin-pictures/#findComment-518794 Share on other sites More sharing options...
jonsjava Posted April 16, 2008 Share Posted April 16, 2008 oops, forgot to mention, when you call the function, do it this way: returnimages($dirname); Link to comment https://forums.phpfreaks.com/topic/101416-solved-stinkin-pictures/#findComment-518797 Share on other sites More sharing options...
phpretard Posted April 16, 2008 Author Share Posted April 16, 2008 No more stinkin' pictures Link to comment https://forums.phpfreaks.com/topic/101416-solved-stinkin-pictures/#findComment-518804 Share on other sites More sharing options...
jonsjava Posted April 16, 2008 Share Posted April 16, 2008 <?php while($row = mysql_fetch_array($result)) { $lastname=$row['lastname']; $firstname=$row['firstname']; echo $firstname ." ". $lastname; } $dirname = "ALBUMS/".$lastname; function returnimages($dirname) { $galleryarray = array(); $pattern="\.(jpg|jpeg|png|gif|bmp)$"; $files = array(); $curimage=0; if($handle = opendir($dirname)) { while(false !== ($file = readdir($handle))){ if(eregi($pattern, $file)){ $galleryarray[$curimage]=$file; $curimage++; } } closedir($handle); } return($files); } returnimages(); ?> re-worked, but without having the full code, I can't promise it will work. Link to comment https://forums.phpfreaks.com/topic/101416-solved-stinkin-pictures/#findComment-518809 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.