WebmasterLingo
JustEdge Dedicated Servers

Go Back   WebmasterLingo > Programming Corner
User Name
Password

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
Old September 18th, 2005, 04:42 PM   #1
I, Brian
Registered User
 
Join Date: Sep 2005
Posts: 4
I, Brian is on a distinguished road
Random content order?

Sorry to ask a simple question, but I'm looking to randomise a display of content, which are called up with basic PHP include files.

So if there are 5 images, I'm calling them up as:

Code:
<!-- site content above --> <?PHP include("/home/user/public_html/section1.php"); ?> <?PHP include("/home/user/public_html/section2.php"); ?> <?PHP include("/home/user/public_html/section3.php"); ?> <?PHP include("/home/user/public_html/section4.php"); ?> <?PHP include("/home/user/public_html/section5.php"); ?> <!-- footer below -->



How would I randomise with a script within the body itself?

Many thanks for any replies.
I, Brian is offline   Reply With Quote
Old September 19th, 2005, 12:21 AM   #2
Marshall
Registered User
 
Join Date: May 2004
Posts: 70
Marshall is off the scale
Send a message via AIM to Marshall
Something like this might work
Code:
<!-- site content above --> <?php $selection = mt_rand(1,5); if($selection == "1"){ include("/home/user/public_html/section1.php"); }elseif($selection == "2"){ include("/home/user/public_html/section2.php"); }elseif($selection == "3"){ include("/home/user/public_html/section3.php"); }elseif($selection == "4"){ include("/home/user/public_html/section4.php"); }else{ include("/home/user/public_html/section5.php"); } ?> <!-- footer below -->
__________________
Eternity-Web Hosting - PHP5 and Directadmin with Installatron Hosting
Marshall is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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



All times are GMT -5. The time now is 06:40 AM.

Windows 2003, cPanel & DirectAdmin Unix Web Hosting