Jump to content

How to limit how many people can choose something in mysql database using php


Delqath

Recommended Posts

I am building a website for a company that has clients sign up for activities on their website.  Everything works using mysql and php, but right now I have to monitor how many people are signed up for each event, and take an event off the page if it is full (ex: only 50 people can sign up for the spa package).  Is there a way for me to either code php to put a limit on how many people can choose an activity, or limit it in the database its self?

 

Thanks in advance

Add two columns to the event table (signed_up = total that have signed up,total_allowed = total number allowed to sign_up [50]) that counts how many have signed up.

 

// query to display opened events, won't show events that are full

 

SELECT * FROM events WHERE signed_up < total_allowed ORDER BY event_date;

 

// when someone signs up

 

UPDATE events SET signed_up = signed_up + 1 WHERE event_id = some_id;

hmm ok sounds like I need to break up my table... I am only using one table right now becuase there are only 3 choices people have to make, but it sounds like breaking it up is the way to go.

 

 

Big or small, always design the your DB with scalability in mind....

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.