Automatically created grids when others are full

Asked

Viewed 32 times

0

I am creating a small website for my friends to have fun in some raffles. Basically what I have in mind is the following:

I’m going to specify in the database how many grids there have to be rolling on the site. These grids are basically vacant for users to enter a "raffle". So we have for example 3 bars, one that costs 10 points each wave another that costs 20 and another that costs 30. This will be specified in the database and the user clicks on the desired spot to enter the "raffle". When all vacancies are filled the draw will take place on Random.org.

What I need to know is how do I keep the site itself recreating these raffles when they’re done. For example, the 10-point raffle closed and was drawn, another 10-point raffle opens and so with the other values as well. I thought of something that check in the database all the time but I know this is not the best solution, I need to know what to do.

1 answer

1


create a RIFA table with the fields:

valor //10, 20 ou 30
idComprador //identifica o usuário por um id vindo de outra tabela (para evitar problemas com usuários com nomes iguais)
vendida //campo boolean

create as many raffle tickets as you want (say 30)

whenever loading the page do something similar to the code below:

select count(*) from rifa where vendida = false and valor = 10; //pega o total de rifas sem vender

if (resultado == 0) //se nao tiver mais rifas para vender
{
    //comando que cria mais rifas
}

this code is just for you to use as a basis to create your

  • 1

    Whoa, thanks bro. I hadn’t thought about it and this way it will work. Vlw even

Browser other questions tagged

You are not signed in. Login or sign up in order to post.