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!

Rand stopped working..

Status
Not open for further replies.

wudz

Programmer
Mar 28, 2001
135
GB
Hi,
The code below was suggested on the Forum a few weeks ago and worked great, that is until I added..

AND (minimum_bid <=10 )

this has caused the radomised selection taking place and unsure why, without it...works great.

<code>
$auctionit = rand(1,$auctionnum);
}


//-- Set offset and limit for pagination

$limit = 20;
if(!$offset) $offset = 0;

$result = mysql_query ("SELECT *, RAND($auctionit) as randy
FROM test_data
WHERE (closed='0') AND (suspended = '0') AND (minimum_bid <=10 )
ORDER BY randy LIMIT 3");

</code>

cheers in anticipation

John

 
Hi Sleipnir,

I just get the last 3 auctions that were posted.

As mentioned,worked great, it picked up 3 random auctions before my addition.

John
 
Hi slepiner,

Yep, I had set another condition in another section which stopped the variable being picked up from the query...
Thanks again for you fast responses to my probsit is greatly appreciated.

I have another question perhaps you may guide me how to achive it. I could use a while loop. but not sure how to extract the data/

I require 3 hot auctions, that is the three with the most bids, and if any have the same number of bids then choose the one/s with the most viewing.

I have $num_bids, $auction_id and $viewed all in the same table so no problems there.

How do I do the logic as to pick the three I require.

Should I start a new post for the above? suppose it may help others if I do.

Cheers

John



 
John

I'd advise starting another thread as this is a different issue.

Also give enough information for readers to help. e.g. your table structure (at least those fields that are relevant), a description of what goes in those fields if it is not evident and an example of what you want back.

Justin
 
Cheers Justin,

Just called home, will set up a new post tonight with more info
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top