Forum Moderators: coopster
I'm looking for an easy method to implement an 'entry form' for an online competition on my website (a competition page, if you like).
As I am running a 'trade promotion' I will need to apply for a trade permit license, therefore will need to satisfy the local authorities that the entry form and drawing method are acceptible.
The competition page will feature the prize on offer and the fields for entrants to fill in their details.
The tricky part I think is that I then require the entries to be able to be 'drawn randomly' once the competition has ended. Any tips here on how to successfully and easily run a competition from your site?
Many thanks to all in advance
one possibility
each entry has a unique id attributed to it on insert.
if the first one is 1 and you
select max(entry_id) as lastentry from yourtable;
you will now have the range of entries to pull from randomly. You could then do something similar to this
$winner = rand(1,$lastentry);
select * from yourtable where entry_id=$winner;
You would just have to handle it in case that particular id doesn't exist.
you could also pull randomly using the query itself but I just didn't go that way. ;)