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?

5
Contributors
7
Replies
8
Views
7 Years
Discussion Span
Last Post by vincent2085
0

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.

0

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.

0

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

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.

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.

0

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.

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.