Grids automatically created when others are full

0

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

I will specify in the database how many grids there have to be rolling in the site. These grids are basically vague for users to enter into a "raffle". So we have for example 3 grids, one that costs 10 points each other vacancy that costs 20 and another that costs 30. This will be specified in the database and the user clicks on the desired vacancy to enter the "raffle". When all the vacancies are filled the draw will happen at random.org.

What I need to know is how I keep the site re-creating these raffles when they are 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 checks in the database all the time but I know this is not quite the best solution, I need to know what to do.

    
asked by anonymous 17.12.2016 / 03:17

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 raffles as you want from each (say 30)

Whenever you load 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 only for you to use as a basis to create your

    
17.12.2016 / 03:46