[advanced search]
Results from the most recent live auction are here.
11 members in the live chat room. Join Chat!
Register Rules & FAQ NP$ Store Active Threads Mark Forums Read
Domain Name Industry Newsletter
Go Back   NamePros.Com > Design and Development > Web Design Discussion
User Name
Password

Old 07-29-2003, 05:03 PM   · #1
skuba
New Member
 
Trader Rating: (0)
Join Date: Jul 2003
Posts: 7
NP$: 10.00 (Donate)
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


Please register or log-in into NamePros to hide ads
skuba is offline   Reply With Quote
Old 07-29-2003, 06:32 PM   · #2
deadserious
Senior Member
 
Trader Rating: (13)
Join Date: Aug 2002
Posts: 1,300
NP$: 2.85 (Donate)
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:
<?
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($images, 1);
$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   Reply With Quote
Old 07-29-2003, 06:38 PM   · #3
skuba
New Member
 
Trader Rating: (0)
Join Date: Jul 2003
Posts: 7
NP$: 10.00 (Donate)
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   Reply With Quote
Old 07-29-2003, 08:47 PM   · #4
deadserious
Senior Member
 
Trader Rating: (13)
Join Date: Aug 2002
Posts: 1,300
NP$: 2.85 (Donate)
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   Reply With Quote
Old 07-30-2003, 10:08 AM   · #5
skuba
New Member
 
Trader Rating: (0)
Join Date: Jul 2003
Posts: 7
NP$: 10.00 (Donate)
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   Reply With Quote
Old 07-30-2003, 11:01 AM   · #6
deadserious
Senior Member
 
Trader Rating: (13)
Join Date: Aug 2002
Posts: 1,300
NP$: 2.85 (Donate)
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.

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   Reply With Quote
Old 07-30-2003, 11:11 AM   · #7
skuba
New Member
 
Trader Rating: (0)
Join Date: Jul 2003
Posts: 7
NP$: 10.00 (Donate)
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   Reply With Quote
Closed Thread

NamePros is a revenue sharing forum.

Thread Tools

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
Forum Jump


Site Sponsors
Bored? Visit Blugah.com! Hand-picked games added everyday! Hunting Moon Traffic Down Under
Advertise your business at NamePros
All times are GMT -7. The time now is 07:36 AM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0