You are here: Re: help needed w/prize draw script « All PHP « IT news, forums, messages
Re: help needed w/prize draw script

Posted by dimo414 on 10/10/06 07:26

cashmere@t-online.de wrote:
> hi-ya folks,
> some big-hearted folks helped me here before and I'm hoping I'll be
> lucky again!
> Here's my prob: At work, they have a prize draw script (which I don't
> have access to), and there are 5 winning nos. out of a total of 5000
> numbers.
> Currently a table is created in mysql that contains 5000 rows and
> apparently this is slow because each time you use one of your virtual
> tickets the number is compared to all the numbers in the table.
> I rashly claimed I could solve the prob, and my idea was to just have 5
> rows with the winning numbers where there would be a column containing
> a randomly generated number that was re-generated every time a punter
> had a go, and this number was compared to the ticket number.
> But now I've been given more explicit instructions, namely the logic
> has to be not in the table, but in the php. When a ticket is played,
> the number of winning numbers is diminished from 5 to 4, if it was a
> winner, or the losing numbers are diminished from 4995 to 4994 if it
> was a losing number.
> The draw is over when the number of winning numbers reaches zero,
> obviously.
> At this moment I don't have a clue where to start, even after some days
> of pondering, so I would be verrrry grateful for any pointers.
> TIA Dave

What about having tickets issued sequentially, and the five winning
numbers generated at random, and stored in the database? When someone
receives a ticket that has the same number as the randomly generated
winning ticket, their name (or some other way to identify them) is
stored as a winner for that ticket. Since tickets are issued
sequentially, you don't need to deal with diminishing the number of
wining tickets left, or the number of losing tickets. The only thing
you need to store is the number of the last ticket handed out; so if
the last time the script ran, somoene was given #2345, the script takes
that, adds one, and issues the next ticket. If the issued number
(2346, in my example) is one of the selected tickets, the person who
got the ticket is stored in the database as the winner of that number.

Hope that made sense...

Michael

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация