May 14, 200917 yr Hi, Got an information box on a site. Its all in one div, need something so that I can create, say 5 or 6 divs, and the page picks one at random every-time it loads, and displays this one. So different divs show when you go to the site on different occasions. Man thanks, Jonathan Padhiar
May 14, 200917 yr Hi, Got an information box on a site. Its all in one div, need something so that I can create, say 5 or 6 divs, and the page picks one at random every-time it loads, and displays this one. So different divs show when you go to the site on different occasions. Man thanks, Jonathan Padhiar Maybe consider using rand() php function and CSS for display:none.. just a thought
May 14, 200917 yr Building on what's a;ready been said. you could do something like <div id="my_div<?php echo rand(1,5); ?>"> <p>Here is content</p> </div> EDIT: disreguard that as it will only change div's style!.... wake up Dave.. You could put the content in includes and randomly choose one. <?php $rn = rand(1,5); include('content'.$rn.'.inc.php'); ?>
May 14, 200917 yr Based on the suggestions above... If you have all the divs on the page is to initially set their CSS to display:none; Each div would have to have a class such as content1, content2 etc In your page header, you could have a style declaration as follows: <style type="text/css"> content<?php echo rand(1,5); ?> { display:block; } </style> That will make a random block visible, and the others remain hidden. Though I prefer the idea of using includes, I'd do it that way myself. I used to have a CGI script that would work too, but I can't seem to find it.
Create an account or sign in to comment