Old 12-06-2005   #1 (permalink)
Registered User
 
supafly's Avatar
 

Join Date: May 2004
Location: Preston England on the west side
Posts: 290
Images: 26

Send a message via MSN to supafly
Wink Random images php code?

Can anyone help me with this I want pref a php code to show a random image thumbnail from a folder that is linked to the gallery pages! I don't really want anything to big just a code so I can use it a few times linking diffrent random images to other pages

if you get what I mean
__________________
supafly is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 12-06-2005   #2 (permalink)
Registered User
 
scrowler's Avatar
 
Snake Champion!
Join Date: Feb 2004
Location: New Zealand
Posts: 590
Images: 7

Send a message via MSN to scrowler
Code:
<?php

$files = glob("foldername/*.*");

mt_srand( (double) microtime() * 1000000 );
$num = mt_rand(0, count($files)-1);

echo '<img src="'.$files[$num].'" alt="" />';

?>
__________________
BioRUST Tutorials - the birthplace
scrowler is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 12-06-2005   #3 (permalink)
Registered User
 
supafly's Avatar
 

Join Date: May 2004
Location: Preston England on the west side
Posts: 290
Images: 26

Send a message via MSN to supafly
oooh thank you me dear mucho kisses for you!
__________________
supafly is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 12-06-2005   #4 (permalink)
Registered User
 
scrowler's Avatar
 
Snake Champion!
Join Date: Feb 2004
Location: New Zealand
Posts: 590
Images: 7

Send a message via MSN to scrowler
lol, no problem [25 character minimum........]grrrrrrrrrrrrrrrr
__________________
BioRUST Tutorials - the birthplace
scrowler is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 12-06-2005   #5 (permalink)
ParaSnake
Guest
 

Posts: n/a

i uses array_rand to handle the random,thx Scrow for the new idea
 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 12-06-2005   #6 (permalink)
Registered User
 
scrowler's Avatar
 
Snake Champion!
Join Date: Feb 2004
Location: New Zealand
Posts: 590
Images: 7

Send a message via MSN to scrowler
yeah, there are various ways of doing it... i'll explain what a couple of the functions do:

glob() - retrieves a list of all files in a directory by the supplied flags (* is everything) and returns them in an array

mt_srand() - seeds the better random number generator

mt_rand() - generates a number using the better random number generator [better version of rand()]

count() - returns the number of keys in an array, we use it in this instance to find the maximum array key so we can choose a random one. also see sizeof()
__________________
BioRUST Tutorials - the birthplace
scrowler is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 12-07-2005   #7 (permalink)
Registered User
 
supafly's Avatar
 

Join Date: May 2004
Location: Preston England on the west side
Posts: 290
Images: 26

Send a message via MSN to supafly
Quote:
Originally Posted by scrowler
yeah, there are various ways of doing it... i'll explain what a couple of the functions do:

glob() - retrieves a list of all files in a directory by the supplied flags (* is everything) and returns them in an array

mt_srand() - seeds the better random number generator

mt_rand() - generates a number using the better random number generator [better version of rand()]

count() - returns the number of keys in an array, we use it in this instance to find the maximum array key so we can choose a random one. also see sizeof()


I must find a course to learn php!
__________________
supafly is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 12-07-2005   #8 (permalink)
Registered User
 
scrowler's Avatar
 
Snake Champion!
Join Date: Feb 2004
Location: New Zealand
Posts: 590
Images: 7

Send a message via MSN to scrowler
Quote:
Originally Posted by supafly
I must find a course to learn php!
http://www.php.net/tut - "a simple tutorial"
__________________
BioRUST Tutorials - the birthplace
scrowler is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Closed Thread

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

BB 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
random 50mm 1.8 automaton2 Photography & Photo Manipulation 3 12-19-2007 06:37 PM
Random Image Verification B44h HTML / PHP / ASP / JS 3 08-21-2006 01:03 AM
2 Random Creations Rogan Showrooms & Works In Progress 6 01-09-2006 12:54 PM
Overlapping Images: Putting images on top of another jasonchan483 Adobe Photoshop 5 07-30-2005 11:29 AM
PHP Help, random stuff kp606-Epsilon HTML / PHP / ASP / JS 3 10-30-2004 10:51 AM


All times are GMT +1. The time now is 04:34 AM.

Powered by vBulletin Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.2

Design & Content © BioRUST 2008 :: PRIVACY STATEMENT :: LEGAL INFORMATION :: ADVERTISING MEDIA KIT