1

I'm doing an advertising feature on a website: The more you pay, the likelier the advert is to show.

How would I go about programming this in PHP?

I've not started at all yet because I have no idea of the implementation I could do, especially choosing the advert to display. Given that a person could bid as much money as they want, how would I make it biased towards the higher payers,

So for example, Troy payed 500 and Jane payed 1500, if they are the only two advertising right now, there's a 3/4 chance of Jane's advert showing, and a 1/4 chance of Troy's advert showing.

Given that $adverts is a mysql_query of all the running adverts with the columns: AdvertID | MoneyPayed How would I choose the ID to show?

Ashley Davies
  • 1,790
  • 1
  • 22
  • 41

1 Answers1

1

Thanks to Dagon for linking me to this, it solved my problem:

Random weighted selection of an event

Notably the link which was there which explained the answer:

http://pastebin.com/qTTEWK8u

Community
  • 1
  • 1
Ashley Davies
  • 1,790
  • 1
  • 22
  • 41