Delqath Posted February 13, 2009 Share Posted February 13, 2009 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 Link to comment https://forums.phpfreaks.com/topic/145109-how-to-limit-how-many-people-can-choose-something-in-mysql-database-using-php/ Share on other sites More sharing options...
The Little Guy Posted February 13, 2009 Share Posted February 13, 2009 My best guess would be like this, but it is hard to say without code if(mysql_num_rows($sql) < 50){ // Open still }else{ // Closed } Link to comment https://forums.phpfreaks.com/topic/145109-how-to-limit-how-many-people-can-choose-something-in-mysql-database-using-php/#findComment-761572 Share on other sites More sharing options...
allworknoplay Posted February 13, 2009 Share Posted February 13, 2009 This is easy. Everytime the page loads, it does a count on your tables for each of your categories. If less than 50, then you display the category. If not, then you display it. Link to comment https://forums.phpfreaks.com/topic/145109-how-to-limit-how-many-people-can-choose-something-in-mysql-database-using-php/#findComment-761574 Share on other sites More sharing options...
Delqath Posted February 13, 2009 Author Share Posted February 13, 2009 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. Link to comment https://forums.phpfreaks.com/topic/145109-how-to-limit-how-many-people-can-choose-something-in-mysql-database-using-php/#findComment-761577 Share on other sites More sharing options...
printf Posted February 13, 2009 Share Posted February 13, 2009 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; Link to comment https://forums.phpfreaks.com/topic/145109-how-to-limit-how-many-people-can-choose-something-in-mysql-database-using-php/#findComment-761578 Share on other sites More sharing options...
allworknoplay Posted February 13, 2009 Share Posted February 13, 2009 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.... Link to comment https://forums.phpfreaks.com/topic/145109-how-to-limit-how-many-people-can-choose-something-in-mysql-database-using-php/#findComment-761581 Share on other sites More sharing options...
The Little Guy Posted February 13, 2009 Share Posted February 13, 2009 if you use a select to get all the people who have a "spa package", then you really don't need to break your table up. Link to comment https://forums.phpfreaks.com/topic/145109-how-to-limit-how-many-people-can-choose-something-in-mysql-database-using-php/#findComment-761582 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.