 |
Results from the most recent live auction are here.
11 members in the live chat room. Join Chat!
| |
07-29-2003, 05:03 PM
|
· #1 | | New Member | 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 |
| |
07-29-2003, 06:32 PM
|
· #2 | | Senior Member Join Date: Aug 2002
Posts: 1,300
NP$: 2.85 ( Donate)
| 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:
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.  |
| |
07-29-2003, 06:38 PM
|
· #3 | | New Member | 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 |
| |
07-29-2003, 08:47 PM
|
· #4 | | Senior Member Join Date: Aug 2002
Posts: 1,300
NP$: 2.85 ( Donate)
| 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. |
| |
07-30-2003, 10:08 AM
|
· #5 | | New Member | 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 |
| |
07-30-2003, 11:01 AM
|
· #6 | | Senior Member Join Date: Aug 2002
Posts: 1,300
NP$: 2.85 ( Donate)
| 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. |
| |
07-30-2003, 11:11 AM
|
· #7 | | New Member | 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!!! |
| |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | |