HighDots Forums  

different image everytime page is refreshed

Macromedia Dreamweaver Macromedia Dreamweaver Discussions (macromedia.dreamweaver)


Discuss different image everytime page is refreshed in the Macromedia Dreamweaver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
IzB
 
Posts: n/a

Default different image everytime page is refreshed - 07-05-2004 , 02:19 PM






I found this site: http://www.carltonward.com
Everytime the index page is refreshed, a different image pops up.
I'm not proficient with code yet, and I was wondering if someone could help me
figure out how to make this happen.
What code is being used and where should it be placed?

Thanks for your time...

www.isaacbrown.net



Reply With Quote
  #2  
Old   
Shaun
 
Posts: n/a

Default Re: different image everytime page is refreshed - 07-05-2004 , 02:33 PM






You could store all your images in a directory and name them 1,2,3,4,5. Then
use your scriptin language to generate a random number.

In PHP this would look something like:

<img src="images/<? echo rand(1, 5); ?>.jpg">

HTH

"IzB" <webforumsuser (AT) macromedia (DOT) com> wrote

Quote:
I found this site: http://www.carltonward.com
Everytime the index page is refreshed, a different image pops up.
I'm not proficient with code yet, and I was wondering if someone could
help me
figure out how to make this happen.
What code is being used and where should it be placed?

Thanks for your time...

www.isaacbrown.net





Reply With Quote
  #3  
Old   
Alan
 
Posts: n/a

Default Re: different image everytime page is refreshed - 07-05-2004 , 02:37 PM



if you want it easy and to use client-side javascript, visit
http://kaosweaver.com and get the free random image extension or the
advanced commercial version.

and- it's a good idea to put in <noscript><img
src="oneoftheimages.jpg"></noscript>

so that an image will load for those with JS turned off.

Quote:
I found this site: http://www.carltonward.com
Everytime the index page is refreshed, a different image pops up.
I'm not proficient with code yet, and I was wondering if someone could help me
figure out how to make this happen.
What code is being used and where should it be placed?

Thanks for your time...

www.isaacbrown.net




Reply With Quote
  #4  
Old   
Michael Fesser
 
Posts: n/a

Default Re: different image everytime page is refreshed - 07-05-2004 , 03:29 PM



.oO(Shaun)

Quote:
You could store all your images in a directory and name them 1,2,3,4,5. Then
use your scriptin language to generate a random number.

In PHP this would look something like:

img src="images/<? echo rand(1, 5); ?>.jpg"
OK, but:

If you want your code be reliable and portable you should avoid short
open tags and use the correct <?php ... ?> instead. Short open tags
could be disabled on some machines and are a problem if you use XML.

Micha


Reply With Quote
  #5  
Old   
IzB
 
Posts: n/a

Default Re: different image everytime page is refreshed - 07-05-2004 , 04:15 PM



Thanks for the feedback.
Two questions for you:

1. Where exactly should I insert that code snippet (<noscript><img
src="oneoftheimages.jpg"></noscript>) ?

2. How would one go about turning their java script on and off?

Thanks again!



Reply With Quote
  #6  
Old   
Shaun
 
Posts: n/a

Default Re: different image everytime page is refreshed - 07-05-2004 , 04:36 PM



"Michael Fesser" <netizen (AT) gmx (DOT) net> wrote

Quote:
.oO(Shaun)

You could store all your images in a directory and name them 1,2,3,4,5.
Then
use your scriptin language to generate a random number.

In PHP this would look something like:

img src="images/<? echo rand(1, 5); ?>.jpg"

OK, but:

If you want your code be reliable and portable you should avoid short
open tags and use the correct <?php ... ?> instead. Short open tags
could be disabled on some machines and are a problem if you use XML.

Micha
Hi Micha,

Thanks I didn't know that, how about using this format for inserting code
into HTML <?=$myVar?>




Reply With Quote
  #7  
Old   
Michael Fesser
 
Posts: n/a

Default Re: different image everytime page is refreshed - 07-05-2004 , 05:18 PM



.oO(Shaun)

Quote:
Thanks I didn't know that, how about using this format for inserting code
into HTML <?=$myVar?
It's the same, it's a short tag (same as <? echo $myVar?>). As said
before - this may be convenient, but could be disabled in the server
configuration. And if you want to output an XML prolog somewhere (for
example in an XHTML document with embedded PHP code) ...

<?xml version="..." encoding="...">

.... you're in trouble because PHP interprets the <? as its own start
tag, which will cause a parse error in the code above.

There are some comments and recommendations in the manual:

Escaping from HTML
http://www.php.net/manual/en/language.basic-syntax.php#language.basic-syntax.phpmode

short_open_tag
http://www.php.net/manual/en/ini.sect.language-options.php#ini.short-open-tag

Quote:
"Using short tags should be avoided when developing applications or
libraries that are meant for redistribution, or deployment on PHP
servers which are not under your control, because short tags may not be
supported on the target server. For portable, redistributable code, be
sure not to use short tags."

Micha


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.