Do you have a question? Post it now! No Registration Necessary. Now with pictures!
May 15, 2005, 10:55 am
rate this thread
I am managing banners visualization using a php/mysql script.
Currently, the banner is extracted from a table using a "select * from
banners order by rand limit 1" query.
Anyway this is a completely random extraction. I would like to
introduce a weight in order to have some banner extracted more
frequently. Is there any way to do this (note that I can not modify the
table adding more times the same banners).
Re: a weighted order by rand()?
*** firstname.lastname@example.org wrote/escribió (15 May 2005 05:55:33 -0700):
I haven't done the math to calculate probabilities but...
select rand()*weight as random_position
order by random_position desc
-- Álvaro G. Vicario - Burgos, Spain
-- http://bits.demogracia.com - Mi sitio sobre programación web
-- Don't e-mail me your questions, post them to the group