kosaic Posted December 1, 2009 Share Posted December 1, 2009 I have this code running, and it works perfectly … however, see my bottom bit about what I see when I view source, versus what I want to see … I am having image re-sizing issues that started when I use this code. When I hard code img tags directly to the images, all works fine. rotate.php <?php $images=array( "darin_1.jpg", "darin_2.jpg", "jeffb_1.jpg", "jeffb_2.jpg", "jeffb_3.jpg", "glenda_1.jpg", "glenda_2.jpg", "glenda_3.jpg", "glenda_4.jpg", "kevin_1.jpg", "kevin_2.jpg", "kevin_3.jpg", "kevin_4.jpg", "petrina_1.jpg", "petrina_2.jpg", "mia_1.jpg", "mia_2.jpg", "dale_1.jpg", "paul_1.jpg", "raino_1.jpg", "raino_2.jpg", "raino_3.jpg", "sherri_1.jpg", "sherri_2.jpg" ); $total=count($images); $secondsFixed=5; // seconds to keep list the same $seedValue=(int)(time()/$secondsFixed); srand($seedValue); for ($i=0;$i<$total;++$i) // shuffle list 'randomly' { $r=rand(0,$total-1); $temp =$images[$i]; $images[$i]=$images[$r]; $images[$r]=$temp; } $index=(int)($_GET['i']); // image index passed in $i=$index%$total; // make sure index always in bounds $file=$images[$i]; header("Location: $file"); // and pass file reference back ?> In my PHP page I have: <img src="profiles/images/rotate.php?i=1" alt="" border="1" width="90" height="90"/> <img src="profiles/images/rotate.php?i=2" alt="" border="1" width="90" height="90"/> <img src="profiles/images/rotate.php?i=3" alt="" border="1" width="90" height="90"/> Etc …. When I view Source, I see: (for every one of them …) <img src="profiles/images/rotate.php?i=1" alt="" border="1" width="90" height="90"/> <img src="profiles/images/rotate.php?i=2" alt="" border="1" width="90" height="90"/> <img src="profiles/images/rotate.php?i=3" alt="" border="1" width="90" height="90"/> Etc…. I want to see the actual image name (darin_1.jpg for example) in the line immediately about this. <img src="profiles/images/darin_1.jpg" alt="" border="1" width="90" height="90"/> <img src="profiles/images/darin_2.jpg" alt="" border="1" width="90" height="90"/> <img src="profiles/images/jeffb_1.jpg" alt="" border="1" width="90" height="90"/> How do I print the value of that array object in my <img> tag, as opposed to it displaying "rotate.php?i=1" ?? Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/183630-php-webpage-array-print-issue/ Share on other sites More sharing options...
kosaic Posted December 1, 2009 Author Share Posted December 1, 2009 Bump (sorry, I'm in a pinch) Quote Link to comment https://forums.phpfreaks.com/topic/183630-php-webpage-array-print-issue/#findComment-969292 Share on other sites More sharing options...
kosaic Posted December 3, 2009 Author Share Posted December 3, 2009 BUMP ... anyone ? Quote Link to comment https://forums.phpfreaks.com/topic/183630-php-webpage-array-print-issue/#findComment-970257 Share on other sites More sharing options...
premiso Posted December 3, 2009 Share Posted December 3, 2009 In order to do what you want, you will need to utilize mod_rewrite and parse/send any .jpg's to your image script to process, this can be tricky as you probably have normal jpgs on your server that do not require that script to display. But yea, you want to look into mod_rewrite for Apache. Quote Link to comment https://forums.phpfreaks.com/topic/183630-php-webpage-array-print-issue/#findComment-970266 Share on other sites More sharing options...
kosaic Posted December 3, 2009 Author Share Posted December 3, 2009 Is there no simple way to print the actual object name from the array, in my .php page ? Something like: (for example) <?php print(rotate.php?i=1) ?> .... which would in turn print "darin_1.jpg" in my source Quote Link to comment https://forums.phpfreaks.com/topic/183630-php-webpage-array-print-issue/#findComment-970497 Share on other sites More sharing options...
premiso Posted December 3, 2009 Share Posted December 3, 2009 Nope, the reasoning for it is that you need to access that script to get the image. If you just type in image.jpg, there is no image.jpg on the server and without a mod_rewrite being setup to put that through the script the server just sees it as a 404 Page Not Found. Unfortunately that is just how it is. Quote Link to comment https://forums.phpfreaks.com/topic/183630-php-webpage-array-print-issue/#findComment-970527 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.