prime Posted July 12, 2007 Share Posted July 12, 2007 I've tried to design a random picture generation script for my forums..... it works on firefox though all it does on I.E and opera is to create the picture error red box, also it does create some weird html, and I've tried fixing this but been having problems. Also how would I be able to modify this to store the pictures in a subfolder called avatars, everytime I try the code doesn't even work for FF. Thank you here's the code Thank you <?php //random picture generation script //1st picture stored pics $pics1 = array('princeoutfit-Front.gif','prime1.png'); //2nd picture $pics2 = array('lunarprime.png','ranger prime.gif'); //3rd picture stored $pics3 = array('princeoutfit-Back.gif','shadeprime.png'); //4th pictures stored $pics4 = array('prime2.png','shadow-sword.gif',); srand ((float)microtime()*1000000); //Shuffle 1st pic shuffle ($pics1); shuffle ($pics1); //Shuffle 2nd pic shuffle ($pics2); shuffle ($pics2); //shuffle 3rd pic shuffle ($pics3); shuffle ($pics3); //shuffle 4th pic shuffle ($pics4); shuffle ($pics4); ?> <div align="center"> <br/><br/><br/><br/><br/><br/>     <?php /*<img src="images/prime1.png" alt="prime" width="43" height="120"> */ ?> <?php /*1st Picture*/ ?> <img src="<?php for ($i = 0; $i < 2; $i++) { echo '<img src="'; echo $pics1[$i]; } ?>" alt="left1" width="43" height="120">             <?php /*2nd Picture*/ ?> <img src="<?php for ($i = 0; $i < 2; $i++) { echo '<img src="'; echo $pics2[$i]; } ?>" alt="pic number 2" width="43" height="120"> <b class="biggsubhead">   Welcome     <?php /*3rd Picture*/ ?> <img src="<?php for ($i = 0; $i < 2; $i++) { echo '<img src="'; echo $pics3[$i]; } ?>" alt="right1" width="43" height="120">   <?php /*4th Picture*/ ?> <img src="<?php for ($i = 0; $i < 2; $i++) { echo '<img src="'; echo $pics4[$i]; } ?>" alt="right2" width="43" height="120"> <br/> </b> <b class="subheading"> to Primefalcon's Website </b> <br/><br/> <b class="introtext"> This site is a dedication to my runescape character Primefalcon <br/> and is basically a journal of wherever he ends up and how he got there. <br/> I hope you enjoy this site! </b> <br/><br/> <div align="center"> <b class="author"> Site design and author of Primefalcon site is Bradley Floyd <br/> Graphics Design and text editing by Marlaine Floyd </b></div> Quote Link to comment Share on other sites More sharing options...
teng84 Posted July 12, 2007 Share Posted July 12, 2007 http://www.php.net/manual/en/function.copy.php not sure if thats what you need but try this Quote Link to comment Share on other sites More sharing options...
prime Posted July 12, 2007 Author Share Posted July 12, 2007 Unfortunately no you need I'm trying to get the random generation funtion srand and shuffle to work with those picture files so it displays a random set of pictures in each of those slots each time the page is loaded Quote Link to comment Share on other sites More sharing options...
Caesar Posted July 12, 2007 Share Posted July 12, 2007 If I understood your last post...you want to randomize images that are displayed... <?php $path = 'images/'; $images = array('one.jpg', 'two.jpg', 'three.jpg', 'four.jpg'); $img = $path.$images[rand(0, count($images) - 1)]; echo'<img src="'.$img.'">'; ?> Quote Link to comment Share on other sites More sharing options...
prime Posted July 12, 2007 Author Share Posted July 12, 2007 yes thats correct and with the path you have added, that solves my other problem as well Thank you, also its a lot mroe compact code that I used lol. Thank you very much. Now I just have to insert it into my code thank you again :-) Quote Link to comment Share on other sites More sharing options...
Caesar Posted July 12, 2007 Share Posted July 12, 2007 You're welcome. Happy coding.. Quote Link to comment Share on other sites More sharing options...
prime Posted July 12, 2007 Author Share Posted July 12, 2007 Thank you very much, I had to add a shugffle to actualy make it random though like <?php //random picture generation script //1st Picture $path1 = 'avatar/'; $images1 = array('lunarprime.png','ranger prime.gif'); shuffle ($images1); $img1 = $path1.$images1[rand(0, count($images1) - 1)]; //2nd Picture $path2 = 'avatar/'; $images2 = array('princeoutfit-Front.gif','prime1.png'); shuffle ($images2); $img2 = $path2.$images2[rand(0, count($images2) - 1)]; //3rd Picture $path3 = 'avatar/'; $images3 = array('princeoutfit-Back.gif','shadeprime.png'); shuffle ($images3); $img3 = $path3.$images3[rand(0, count($images3) - 1)]; //4th Picture $path4 = 'avatar/'; $images4 = array('prime2.png','shadow-sword.gif'); shuffle ($images4); $img4 = $path4.$images4[rand(0, count($images4) - 1)]; ?> then with the actually image codes <img src="<?php echo "$img1"; ?>" alt="image1" width="43" height="120"> <img src="<?php echo "$img2"; ?>" alt="image2" width="43" height="120"> <img src="<?php echo "$img3"; ?>" alt="image3" width="43" height="120"> <img src="<?php echo "$img4; ?>" alt="image4" width="43" height="120"> anyhow topic solved thank you very much 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.