Greenguy's Board


Go Back   Greenguy's Board > General Business Knowledge
Register FAQ Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
Old 2003-09-05, 12:05 PM   #1
Sex
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
Sex is offline   Reply With Quote
Old 2003-09-05, 07:07 PM   #2
bret
Shut up brain, or I'll stab you with a Q-tip!
 
bret's Avatar
 
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.
bret is offline   Reply With Quote
Old 2003-09-05, 07:36 PM   #3
Extreme John
Afro John says: "Touch The Extreme Afro & You'll Be In Extreme Pain!"
 
Extreme John's Avatar
 
Join Date: Aug 2003
Location: FL
Posts: 1,671
Send a message via ICQ to Extreme John
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!
__________________

September 6, 2007
Extreme John is offline   Reply With Quote
Old 2003-09-05, 09:52 PM   #4
bret
Shut up brain, or I'll stab you with a Q-tip!
 
bret's Avatar
 
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.
bret is offline   Reply With Quote
Old 2003-09-05, 09:55 PM   #5
Cleo
Subversive filth of the hedonistic decadent West
 
Cleo's Avatar
 
Join Date: Mar 2003
Location: Southeast Florida
Posts: 27,936
I'm impressed, that is amazing.
__________________
Free Rides on Uber and Lyft
Uber Car: uberTzTerri
Lyft Car: TZ896289
Cleo is offline   Reply With Quote
Old 2003-09-07, 08:10 AM   #6
venturi
No offence Apu, but when they were handing out religions you must have been out taking a whizz
 
Join Date: Apr 2003
Location: An Oasis atop a High Desert Mesa
Posts: 282
Send a message via ICQ to venturi
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...
venturi is offline   Reply With Quote
Old 2003-09-07, 05:47 PM   #7
natalie
Whoo! 9/10 the way to buddy plays in "The Christ from Oz"!
 
natalie's Avatar
 
Join Date: Aug 2003
Location: Australia
Posts: 921
Send a message via ICQ to natalie
Heres a quick one i did last week, its hard coded (naughty ) and doesnt use a db but my host is a pain with not letting me do the db myself atm. But it does a random from the case, which you could adapt to use with a db. I use the variables to change the alt tag, img etc on a group of banners. Like i said it was just a quick fix.

<?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; ?>
natalie is offline   Reply With Quote
Reply


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

Forum Jump


All times are GMT -4. The time now is 08:32 AM.


Mark Read
Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
© Greenguy Marketing Inc