Jump to content

[SOLVED] Random Picture generation


prime

Recommended Posts

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/>



&nbsp &nbsp
<?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">

&nbsp &nbsp  &nbsp &nbsp &nbsp &nbsp

<?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">
&nbsp
Welcome
&nbsp  &nbsp  


<?php /*3rd Picture*/ ?>
<img src="<?php

for ($i = 0; $i < 2; $i++)
{
echo '<img src="';
echo $pics3[$i];

} 

?>" alt="right1" width="43" height="120">

&nbsp 

<?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>

Link to comment
https://forums.phpfreaks.com/topic/59548-solved-random-picture-generation/
Share on other sites

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

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.