PHP page switch

Status
Not open for further replies.

maverick

Superstar DJ!
Oct 5, 2006
440
7
0
Button Moon
Im sure i seen a bit of PHP code on this site which lets you change the page every time someone loads it so you could try out diffrent styles. I have searched and cant find it , any pointers
 


I'm too tired now to look for the exact code, will do it later if no one else beats me to it, but you can make a few css files and add some php code in the head part of your html which will choose a different css everytime the page loads, therefore giving the page a different look.
 
<link rel="stylesheet" type="text/css" href="stylesheet<?=rand(1,3)?>.css">

<?= is shorthand for outputting text
rand(0,3) will randomly choose a number, either 1 2 or 3

dont know if that's what you were looking for but that will randomly choose either stylesheet1.css, stylesheet2.css, or stylesheet3.css
 
I have a similar way to what stanley posted, but his is a lot cleaner than mine. I've used it to swap banners
 
Status
Not open for further replies.