NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Web Design Discussion
Reload this Page How to load a different page each time page refreshes?

Web Design Discussion Discussion of web design techniques, advice, browser issues, software, design firms.

Advanced Search
10 members in live chat ~  
NamePros Design Contests NamePros Design Contests
Forum Sponsorship
Join in on the FUN! You can start an affordable design contest and pick from entries talented members submit or you can enter a design contest for a chance to win CASH PRIZES! What are you waiting for? Get started in the fun TODAY! - Banners, Logos, Mascots, and MORE! (Please READ the design Contest section rules Prior to starting or entering a contest)



Closed Thread
 
LinkBack Thread Tools
Old 07-29-2003, 04:03 PM THREAD STARTER               #1 (permalink)
New Member
Join Date: Jul 2003
Posts: 7
skuba is an unknown quantity at this point
 



How to load a different page each time page refreshes?


Hi!
For a new site I am creating, I need to do one of the following options:
- Load a different home page each time user refreshes or enter site (I could be also just changing part of the code in the same page)
- Load different random different images on the home page as a slide show (BUT, it can't be just 1 image. I have a set of 5 images, that need to change to other 5 images).

Do you have any idea how to do eigther those?
It can be a javascript code, HTML, or PHP.

Thanks
skuba is offline  
Old 07-29-2003, 05:32 PM   #2 (permalink)
Senior Member
Join Date: Aug 2002
Posts: 1,255
deadserious has a spectacular aura aboutdeadserious has a spectacular aura about
 



Something like this should probably work for everything you're wanting to do with some slight modification.

Add this in your php page somewhere:
PHP Code:
<?
????: NamePros.com http://www.namepros.com/web-design-discussion/15074-how-load-different-page-each-time.html
srand
((double)microtime() * 10000000);
$images = array(
"Random image: <img src ="http://yourdomain.ext/pic1.gif" border="0">", 
"Some Random Code: <font color ="blue">This is blue</font>"
"A Random quote: Some quote",
"Random Image 2:<img src ="http://yourdomain.ext/pic2.jpg" border="0">" 
);
$select array_rand($images1);
$random $images[$select];
?>
Then add this where ever you want the random picture, code, quote, or whatever else you put in there to show up:
PHP Code:
<? echo $random?>
You can add as many as you'd like just follow the same format. You can make it all images or whatever you want.

You could also make it select a random page using includes and/or a switch statement or something like that.
deadserious is offline  
Old 07-29-2003, 05:38 PM THREAD STARTER               #3 (permalink)
New Member
Join Date: Jul 2003
Posts: 7
skuba is an unknown quantity at this point
 



question


Thanks for the response. But I have a question.
The home page is not in PHP. Should I make another PHO page that will be accessed from the HMTL home page? or I just include that code in the HTML and it will work?
Thanks
skuba is offline  
Old 07-29-2003, 07:47 PM   #4 (permalink)
Senior Member
Join Date: Aug 2002
Posts: 1,255
deadserious has a spectacular aura aboutdeadserious has a spectacular aura about
 



If you want to use that on your page it would need to be a php file. You could just rename your page so it has .php extension rather than a .html extension and throw that code in it if your server supports php.

Otherwise you'll probably want to use JavaScript.
deadserious is offline  
Old 07-30-2003, 09:08 AM THREAD STARTER               #5 (permalink)
New Member
Join Date: Jul 2003
Posts: 7
skuba is an unknown quantity at this point
 



The problem is that is my index.html page, the home page. SO I can't rename it or won't work, also I don't want to have anothe rindex.html redirecting to this php page.
Is there another solution?
Thanks
skuba is offline  
Old 07-30-2003, 10:01 AM   #6 (permalink)
Senior Member
Join Date: Aug 2002
Posts: 1,255
deadserious has a spectacular aura aboutdeadserious has a spectacular aura about
 



So your host doesn't allow you to use index.php as your default index page?

Have you tried renaming it to index.php to verify that it does or doesn't work?

I would bet that they do, but it is possible they don't.

I know alot of servers will be set up to allow you to use either index.html index.htm index.php index.php3 index.php4 index.shtml and others as the index page. The index pages will probably be searched for similar to that order also. So first it will look for index.html, then if it don't exist, look for index.htm, then index.php etc., just depending on how they have it set up.
????: NamePros.com http://www.namepros.com/showthread.php?t=15074

Also you can actually rename all your .html files to .php files and they should work just the same. There's no real reason to do that though, unless your going to be using some php code.
deadserious is offline  
Old 07-30-2003, 10:11 AM THREAD STARTER               #7 (permalink)
New Member
Join Date: Jul 2003
Posts: 7
skuba is an unknown quantity at this point
 



Great


Great it works! I renamed the index,html to index.php

Now, I have a question about the code. I have to set the whole array of images to be randomized right? Can't I just tell the script to go look in a folder and pick one?
Thanks.

What if instead of randomizing images, I want to randomize the HTML code that calls the images? Like in the case I want to load a different set of 5 images each time ?

Thanks again!!!
skuba is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


 
All times are GMT -7. The time now is 07:35 PM.

Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger