|
![]() |
#1 |
Internet! Is that thing still around?
Join Date: Aug 2003
Posts: 1
|
RANDOM script
Hi, I am looking for a script ( PHP )
I want script to display 5 images out of 200, these 5 imasges must be unique ( no repeating ) I think the function "array_rand" must be used but Iam not that good to write a script Thank you |
![]() |
![]() |
![]() |
#2 |
Shut up brain, or I'll stab you with a Q-tip!
Join Date: Aug 2003
Posts: 110
|
Simple. i will give it to you in c++ pseudo-code.
int[] thePictureArray = new int[200]; int[] theSelectedArray = new int[5]; /* fill thePictureArray with your pics, or if they are numberd 1 - 200 skip this step */ int select = 0; int randomNumber = 0; for( select = 0; select < 5; select++ ) { boolean needNewNumber = true; while( needNewNumber ) { needNewNumber = false; /* pick random number 0 - 200 */ randomNumber = random(0, 200); /* check to see if it is used */ int check = 0; for( check = 0; check <= select; check++ ) /* compare the number you picked with the numbers you have used */ if( randomNumber == theSelectedArray[check] ) needNewNumber = true; } theSelectedArray[select] = randomNumber; /* or thePictureArray[randomNumber]; } that shoudl do it. |
![]() |
![]() |
![]() |
#3 |
Afro John says: "Touch The Extreme Afro & You'll Be In Extreme Pain!"
|
Jesus Bret you make it seem as easy as washing your hands.. I expected to come in here and try and send a link to someplace... Nice!
|
![]() |
![]() |
![]() |
#4 |
Shut up brain, or I'll stab you with a Q-tip!
Join Date: Aug 2003
Posts: 110
|
the code may not be perfect. but i was not about to troubleshoot anything. if he can't figure it out from there. oh well. maybe read a book or something.
there are a lot faster ways to do it. but that way is the simplest to understand, i feel. |
![]() |
![]() |
![]() |
#5 |
Subversive filth of the hedonistic decadent West
Join Date: Mar 2003
Location: Southeast Florida
Posts: 27,936
|
I'm impressed, that is amazing.
![]() |
![]() |
![]() |
![]() |
#6 |
No offence Apu, but when they were handing out religions you must have been out taking a whizz
|
If it weren't 5am and I hadn't just spent the past 20 hours rebuilding my computer I'd post the actual PHP code to accomplish exactly what s/he wants.
It's going to use the mt_srand, mt_rand and a couple other functions but is pretty simple to implement. Lemme get a few hours of sleep and I'll post the full code up for yas. ![]() My Kingdom for a pillow and a fully functional computer...
__________________
Please Re-Read The Rules For Sig Files |
![]() |
![]() |
![]() |
#7 |
Whoo! 9/10 the way to buddy plays in "The Christ from Oz"!
|
Heres a quick one i did last week, its hard coded (naughty
![]() <?php $random = rand(0, 4); switch ($random) { case 1: $href="http://refer.ccbill.com/cgi-bin/clicks.cgi?CA=924527-0000&PA=00000"; $imgsrc="images/rotators/460x801.jpg"; $alt="fantastic erotic ezine for women"; $mouseover="http://www.forthegirls.com/"; break; case 2: $href="http://refer.ccbill.com/cgi-bin/clicks.cgi?CA=924527-0000&PA=00000"; $imgsrc="images/rotators/460x802.jpg"; $alt="fantastic erotic ezine for women"; $mouseover="http://www.forthegirls.com/"; break; case 3: $href="http://stats.clearcard.com/servlet/Click?dec2000"; $imgsrc="images/rotators/csban2.jpg"; $alt="Couples Sex Adult Club - Foreplay On the Internet"; $mouseover="http://www.couplessex.com/"; break; case 4: $href="http://stats.clearcard.com/servlet/Click?dec2000"; $imgsrc="images/rotators/banner1c.jpg"; $alt="Couples Sex Adult Club - Foreplay On the Internet"; $mouseover="http://www.couplessex.com/"; break; default: $href="http://refer.ccbill.com/cgi-bin/clicks.cgi?CA=924527-0000&PA=499687"; $imgsrc="images/rotators/460x801.jpg"; $alt="fantastic erotic ezine for women"; $mouseover="http://www.forthegirls.com/"; break; } ?> And put this where you need the variables: <? echo $imgsrc; ?> |
![]() |
![]() |
![]() |
|
|