php-db | 2001062
Date: 06/29/01
- Next message: Hugh Bothwell: "Re: [PHP-DB] most efficient weighting system? URGENT"
- Previous message: olinux o: "[PHP-DB] ereg_replace"
- Next in thread: Hugh Bothwell: "Re: [PHP-DB] most efficient weighting system? URGENT"
- Reply: Hugh Bothwell: "Re: [PHP-DB] most efficient weighting system? URGENT"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
if i have several rows in a table and i want some to have certain weights
what is the best way to pick a random row based on its weight?
ex of table:
id weight
1 10
2 5
3 3
4 20
5 2
therefore, since there is a total weight of 40, id 1 should be picked 25%
(10/40) of the time, id 4 50% (20/40), etc...
what is the best way to do this?
- Noah
-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe <email protected> For additional commands, e-mail: php-db-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: Hugh Bothwell: "Re: [PHP-DB] most efficient weighting system? URGENT"
- Previous message: olinux o: "[PHP-DB] ereg_replace"
- Next in thread: Hugh Bothwell: "Re: [PHP-DB] most efficient weighting system? URGENT"
- Reply: Hugh Bothwell: "Re: [PHP-DB] most efficient weighting system? URGENT"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

