简体   繁体   English

如何限制事件的注册人数?

[英]How can I limit the number of registrants to an event?

I've set up a basic html/php submission form where people can register for our event, but need a way to replace the submission form webpage with one that reads something like "We have reached our registration limit" when we reach a certain number of submitted forms. 我已经建立了一个基本的html / php提交表格,人们可以在其中注册我们的活动,但是需要一种方法来替换提交表格的网页,当达到一定数量时,该网页将显示为“我们已经达到注册限制”提交表格。 Our database is MySQL (if that makes a difference) I've looked around on the web but people either say to count the entries by hand, or the ones that do have an automated system use CMS like drupal or joomla. 我在数据库中浏览过的数据库是MySQL(如果有区别的话),但是人们要么说要手工计数条目,要么说那些拥有自动化系统的条目使用drupal或joomla之类的CMS。 Is it possible to setup an automated script that will do this? 是否可以设置一个自动脚本来做到这一点?

$result = mysql_query("SELECT COUNT(*) FROM Users");
$row = mysql_fetch_row($result);
if ($row[0] > 50) echo 'We have reached our registration limit';

Before you insert a record, count ( SELECT COUNT(*) ) all the previous registrations. 在插入记录之前,请计数( SELECT COUNT(*) )所有先前的注册。 After that all you need to do is a simple if . 之后,您需要做的只是一个简单的if

Remember, DBs queries are executed in sequential order. 请记住,数据库查询是按顺序执行的。

You don't need nothing fancy, I'm not viewing your code, but you can make something like this: 您不需要花哨的东西,我没有查看您的代码,但是您可以执行以下操作:

your_file.php your_file.php

<?

$count = mysql_fetch_array(mysql_query(" SELECT COUNT(*) FROM your_table "));

if ($count<10) {

   // your form code

}else{

  // your "full" message

}

?>

10 -> Max number of people to attend to that event! 10->参加该活动的最大人数!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM