Old 12-05-2005   #1 (permalink)
Face addict
 
supafly's Avatar
 
Join Date: May 2004
Location: Preston England on the west side
Posts: 290

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-05-2005   #2 (permalink)
code anyone?
 
scrowler's Avatar
 
Join Date: Feb 2004
Location: New Zealand
Posts: 590

Send a message via MSN to scrowler Send a message via Skype™ 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-05-2005   #3 (permalink)
Face addict
 
supafly's Avatar
 
Join Date: May 2004
Location: Preston England on the west side
Posts: 290

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-05-2005   #4 (permalink)
code anyone?
 
scrowler's Avatar
 
Join Date: Feb 2004
Location: New Zealand
Posts: 590

Send a message via MSN to scrowler Send a message via Skype™ 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)
Invicible Snake
 
ParaSnake's Avatar
 
Join Date: Sep 2004
Location: Ho Chi Minh City,Vietnam
Posts: 668

Send a message via MSN to ParaSnake Send a message via Yahoo to ParaSnake
i uses array_rand to handle the random,thx Scrow for the new idea
__________________
ParaSnake is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 12-06-2005   #6 (permalink)
code anyone?
 
scrowler's Avatar
 
Join Date: Feb 2004
Location: New Zealand
Posts: 590

Send a message via MSN to scrowler Send a message via Skype™ 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-06-2005   #7 (permalink)
Face addict
 
supafly's Avatar
 
Join Date: May 2004
Location: Preston England on the west side
Posts: 290

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)
code anyone?
 
scrowler's Avatar
 
Join Date: Feb 2004
Location: New Zealand
Posts: 590

Send a message via MSN to scrowler Send a message via Skype™ 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
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Identifying Fake Images Man1c M0g Announcements 0 08-24-2005 10:16 PM
Php Code Denial HTML / PHP / ASP / JS 1 06-17-2005 09:15 AM
my new php sig scrowler HTML / PHP / ASP / JS 12 01-30-2005 01:00 AM
PHP Help, random stuff kp606-Epsilon HTML / PHP / ASP / JS 3 10-30-2004 10:51 AM
Scroll bar code Stiker HTML / PHP / ASP / JS 9 04-19-2004 01:44 PM


All times are GMT +1. The time now is 09:24 AM.
Content Relevant URLs by vBSEO 3.2.0

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