Really stressing me out... please help...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Andrew2010
Forum Newbie
Posts: 4
Joined: Mon Nov 01, 2010 9:59 pm

Really stressing me out... please help...

Post by Andrew2010 »

I can't find any help with this. Ok, here's what I need:

I have a page called woodland.php, where I want a random image in a set position generated on page load. I have this done with HTML, but with that I have to make a page for every image! Seen here:
<script language="JavaScript">

<!-- Begin
var howMany = 10; // max number of items listed below
var page = new Array(howMany+1);

page[0]="earwig.htm";
page[1]="mantis.htm";
page[2]="";
page[3]="";
page[4]="";
page[5]="";
page[6]="firefly.htm";
page[7]="";
page[8]="";
page[9]="ant.htm";
page[10]="";


function rndnumber(){
var randscript = -1;
while (randscript < 0 || randscript > howMany || isNaN(randscript)){
randscript = parseInt(Math.random()*(howMany+1));
}
return randscript;
}
quo = rndnumber();
quox = page[quo];
window.location=(quox);
// End -->
</script>


I place the image I want to load on each page, seen here:
<a href="capture.php"><img style="POSITION: absolute; TOP: 244px; LEFT: 410px" border =0 hspace=0 src ="images/insects/Earwig.png" width=70 height=33 ></a>
Is there a way to generate these images on page load, in the same way as above, but without creating a new page for EVERY image?! There has to be a way to do this with PHP. Once again, I need to generate these images on woodland.php and not having to make a page for every image I generate. This way, users can't find these images with a address.

PLEASE HELP!
cpetercarter
Forum Contributor
Posts: 474
Joined: Sat Jul 25, 2009 2:00 am

Re: Really stressing me out... please help...

Post by cpetercarter »

You have got a large part of the way there. But instead of using your javascript to load the page with the right image, use it to change the src attribute of the img tag. (Better - put no src attribute in your html, use javascript to add it).
Post Reply