Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Not really random

Status
Not open for further replies.

keepingbusy

Programmer
Apr 9, 2000
1,470
GB

Hello guys

I have the following code near the top of a php page:
Code:
$node->orderby = "order by Rand()";
if(($result = $mysql->select($node)) === false ) die($mysql->debugPrint());
I am assuming this is the right forum (apologies if not).

When I view the webpage, the images shown do randomly change but only if I click the refresh button about 3 or 4 times otherwise they stay in the same place.

Is there a way to make this random more frequently?

Thank you
 
You didn't show exact query
I don't know is there any cache in your application
Next, i don't know how many images you have in db.

If you have small number of images you will see many times the same images.

And one thing - usage of order by rand() on big table is not reasonable.
 

Hi nego78

I managed to resolve it by addng some additional lines before the code in bold:
Code:
$node = new sqlNode();
$node->table = "tt_".$type['ID'];
$node->select = "*";
$node->where = "where `Featured` = 'yes' and (`ExpireDate` > NOW())";
[b]$node->orderby = "order by Rand()";[/b]
Each time a visitor views the page, the images are now completely random.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top