Webmaster Forum


Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Coding Forum Problems with your code? Let's hear about it.

Bidding Directory   World's Leading Outsourcing Network   V7N Directory

Reply
 
LinkBack Thread Tools Display Modes
Old 09-14-2005, 10:06 AM   #1 (permalink)
Inactive
 
I, Brian's Avatar
 
Join Date: 10-26-03
Posts: 2,466
iTrader: 0 / 0%
Latest Blog:
None

I, Brian is liked by somebodyI, Brian is liked by somebodyI, Brian is liked by somebodyI, Brian is liked by somebodyI, Brian is liked by somebody
How to randomise the display of 5 includes?

Sorry to ask a simple question, but I'm looking to randomise a display of images, 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/image1.php"); ?> <?PHP include("/home/user/public_html/image2.php"); ?> <?PHP include("/home/user/public_html/image3.php"); ?> <?PHP include("/home/user/public_html/image4.php"); ?> <?PHP include("/home/user/public_html/image5.php"); ?> <!-- footer below -->
How would I randomise with a script within the body itself?

Many thanks for any replies.
I, Brian is offline  
Add Post to del.icio.us
Reply With Quote
Sponsored Links
SEO Hosting by HostGator  Advertise Here  Buy Blog Links
Old 09-14-2005, 07:03 PM   #2 (permalink)
Inactive
 
insitedev's Avatar
 
Join Date: 12-14-04
Posts: 108
iTrader: 0 / 0%
Latest Blog:
None

insitedev is liked by somebodyinsitedev is liked by somebodyinsitedev is liked by somebodyinsitedev is liked by somebody
Very basic:
PHP Code:
<?php
$i 
rand(1,5);
include(
"/home/user/public_html/image" $i ".php");
?>
More flexible:
PHP Code:
<?php
// Insert image pages in this array
$image_pages = array("image1.php""image2.php""image3.php");

$arr_size = (count($image_pages) - 1);
$i rand(0,$arr_size);

include(
"/home/user/public_html/" $image_pages[$i]);
?>

Last edited by insitedev : 09-14-2005 at 07:09 PM.
insitedev is offline  
Add Post to del.icio.us
Reply With Quote
Old 09-15-2005, 07:54 AM   #3 (permalink)
Inactive
 
I, Brian's Avatar
 
Join Date: 10-26-03
Posts: 2,466
iTrader: 0 / 0%
Latest Blog:
None

I, Brian is liked by somebodyI, Brian is liked by somebodyI, Brian is liked by somebodyI, Brian is liked by somebodyI, Brian is liked by somebody
Thanks for the reply - it does work, but I'll ideally looking for the files to be produced in a random order, rather than just one at random - is that possible with PHP?
I, Brian is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum

Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Includes & SEO Imperium SEO Forum 0 09-11-2007 04:41 AM
php includes-what have I done wrong? Jason Coding Forum 12 11-20-2004 09:28 AM
PHP Includes | 404 Error ? samer Coding Forum 2 07-22-2004 11:20 AM
PHP includes GeXus SEO Forum 24 07-09-2004 02:32 AM
PHP dynamic includes vs ASP dynamic includes question! imaginemn Coding Forum 1 06-17-2004 06:55 PM


Sponsor Links
Get exposure! Get exposure! Find Scripts Web Hosting Directory Get exposure! SEO Blog


All times are GMT -7. The time now is 08:51 AM.
© Copyright 2008 V7 Inc