| | |
Limit MySQL Database's Rows
Please support our MySQL advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: May 2009
Posts: 7
Reputation:
Solved Threads: 0
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?
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?
•
•
Join Date: May 2009
Posts: 7
Reputation:
Solved Threads: 0
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.
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
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
•
•
•
•
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.
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.
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.
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 !!!
•
•
Join Date: May 2009
Posts: 7
Reputation:
Solved Threads: 0
•
•
•
•
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.
![]() |
Similar Threads
- CSV file uploading into a MySQL Database? (PHP)
- Display morethan one coulmn from mysql database in PHP (PHP)
- Mysql match and return words in field w/ all rows (MySQL)
- can i use mysql database with asp (ASP)
- Php code confusion. Not sure how to describe (PHP)
- URGENT: UBBThreads MySQL database merge (MySQL)
- Backing up a MySQL database (MySQL)
- Update entire Mysql DataBase with PhP (PHP)
Other Threads in the MySQL Forum
- Previous Thread: Mysql table name with spaces
- Next Thread: 3 letter acroynm
| Thread Tools | Search this Thread |
agplv3 alfresco amazon api artisticlicense aws bizspark breathalyzer camparingtocolumns changingprices cmg communityjournalism contentmanagement contractors copyright count court crm database design developer development distinct drupal dui ec2 email enterprise eudora facebook form foss gartner gnu government gpl greenit groupware hiring hyperic images innerjoins insert ip joebrockmeier join keyword keywords kickfire laptop law legal license licensing linux maintenance managing mariadb matchingcolumns metron micromanage microsoft microsoftexchange mindtouch montywidenius mozilla multiple music mysql mysqlcolumnupdating mysqldatetimeordermax() mysqlindex mysqlinternalqueries mysqlquery mysqlsearch news open-xchange opendatabasealliance opengovernment opensource oracle penelope priceupdating query referencedesign reorderingcolumns resultset saas select sharepoint simpledb sourcecode spotify sql sugarcrm syntax techsupport thunderbird transparency virtualization





