Limit MySQL Database's Rows

Reply

Join Date: May 2009
Posts: 7
Reputation: MArun25039 is an unknown quantity at this point 
Solved Threads: 0
MArun25039 MArun25039 is offline Offline
Newbie Poster

Limit MySQL Database's Rows

 
0
  #1
Sep 17th, 2009
Hello,

I'd like to create a basic html form where a user can submit their email address for a cooking class. There would only be room for 20 people so I'd like it to accept the first 20 user and display a "check back next month" to anyone past 20. I'm not having trouble with the form, or entering in to the database, just limiting it to the 20 entries. Can anyone help?
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 62
Reputation: kylegetson is an unknown quantity at this point 
Solved Threads: 9
kylegetson's Avatar
kylegetson kylegetson is offline Offline
Junior Poster in Training

Re: Limit MySQL Database's Rows

 
0
  #2
Sep 17th, 2009
I dont know of a way to actually limit the table to 20 rows, your better off doing a query and conditionally displaying the form. Count the number of entries in the table, then only display the form if there are less than 20 rows.
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 7
Reputation: MArun25039 is an unknown quantity at this point 
Solved Threads: 0
MArun25039 MArun25039 is offline Offline
Newbie Poster

Re: Limit MySQL Database's Rows

 
0
  #3
Sep 18th, 2009
Originally Posted by kylegetson View Post
I dont know of a way to actually limit the table to 20 rows, your better off doing a query and conditionally displaying the form. Count the number of entries in the table, then only display the form if there are less than 20 rows.
Unfortunately that will not serve my purpose. I essentially need to set a cap on the number of inquiries I can handle per month. If I understand your suggestion, it only limits the number that will display.
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 44
Reputation: guru12 is an unknown quantity at this point 
Solved Threads: 6
guru12's Avatar
guru12 guru12 is offline Offline
Light Poster

Re: Limit MySQL Database's Rows

 
0
  #4
Sep 18th, 2009
Hello Arun

Steps :

1.Count the row of the table
2.if the row counts less tan 20, condition is true other wise condition is false
example:

Select count(id) From table name where condition
---
execute the query

if($row != 20)
{
condition true
}
else
{
condition false
}

Thanks and Regards
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 62
Reputation: kylegetson is an unknown quantity at this point 
Solved Threads: 9
kylegetson's Avatar
kylegetson kylegetson is offline Offline
Junior Poster in Training

Re: Limit MySQL Database's Rows

 
0
  #5
Sep 18th, 2009
Originally Posted by MArun25039 View Post
Unfortunately that will not serve my purpose. I essentially need to set a cap on the number of inquiries I can handle per month. If I understand your suggestion, it only limits the number that will display.
Im not sure you understood what I meant. I am basically saying to not allow a signup if there are already more than 20 rows. So wherever you print out your form, do a query to check the number of rows this month, or whatever conditions need to be met. If there are already too many, display an friendly error, instead of displaying the HTML form. That way, you could limit your inquiries.

Or, if that won't work, you could always have it email you when it inserts the 20th, and you could manually turn it off, but I think the first suggestion will work.
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 823
Reputation: verruckt24 is a jewel in the rough verruckt24 is a jewel in the rough verruckt24 is a jewel in the rough verruckt24 is a jewel in the rough 
Solved Threads: 73
verruckt24's Avatar
verruckt24 verruckt24 is offline Offline
Practically a Posting Shark

Re: Limit MySQL Database's Rows

 
0
  #6
Sep 19th, 2009
Hi MARUN,

As I see there are some discrepancies in your queries here. First you say that you want to limit the entrants to 20 but then in the second one you say you want to limit the enquiries to 20 so that has me a bit confused over your actual requirements but here's my suggestion from what I have understood, point out if I am wrong.

My suggestion is similar to what kylegetson has offered but it has one critical change, since a web form can be seen by n number of people simultaneously instead of checking the rows prior to generating the form you can generate the form unconditionally and then just check while inserting if the rows are <20, if they aren't you can generate a friendly message informaing them of the event or instead you could also add them to a different table registering them early for the next's months batch and informing them accordingly.
Get up every morning and take a look at the Forbes' list of richest people. If your name doesn't appear.... GET TO WORK !!!
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 7
Reputation: MArun25039 is an unknown quantity at this point 
Solved Threads: 0
MArun25039 MArun25039 is offline Offline
Newbie Poster

Re: Limit MySQL Database's Rows

 
0
  #7
Sep 19th, 2009
Originally Posted by kylegetson View Post
Im not sure you understood what I meant. I am basically saying to not allow a signup if there are already more than 20 rows. So wherever you print out your form, do a query to check the number of rows this month, or whatever conditions need to be met. If there are already too many, display an friendly error, instead of displaying the HTML form. That way, you could limit your inquiries.

Or, if that won't work, you could always have it email you when it inserts the 20th, and you could manually turn it off, but I think the first suggestion will work.

Actually your suggestion will work perfectly and most likely the best solution for my situation. I'm sorry I mis-read this the first time, thanks for taking the time to clarify it for me.
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 53
Reputation: vincent2085 can only hope to improve 
Solved Threads: 4
vincent2085 vincent2085 is offline Offline
Banned

Re: Limit MySQL Database's Rows

 
0
  #8
Sep 21st, 2009
yup u look in this site, the best in sql i believe
w3schools.com
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC