Page 1 of 1
Record count
Posted: Tue Feb 14, 2006 1:59 pm
by Eiolon
I made an even sign-up form using MySQL database. Can anyone help me with PHP code so when someone visits the page, it will check the database to see if 20 people have registered. If there has been 20 registrations, it won't show the form. If there haven't been 20 registrations it will show the form.
We are starting to migrate from ColdFusion to PHP and have to re-learn everything

Posted: Tue Feb 14, 2006 3:45 pm
by LiveFree
Code: Select all
$sql=mysql_query("SELECT DISTINCT COUNT(*) FROM users") OR DIE (mysql_error());
$num=mysql_num_rows($sql);
if ($num >=20){
echo "20 Users Registered";
}else{
show_form();
}
Just make show_form() a function (or long echo), to display the form
Happy Valentines Day!
Posted: Tue Feb 14, 2006 5:37 pm
by josh
Code: Select all
$result=mysql_query("SELECT COUNT(*) FROM users") or die (mysql_error());
$num=mysql_result($result,0,0);
mysql_free_result($result);
if ($num >=20){
echo "20 Users Registered";
}else{
show_form();
}
I think your code is wrong, this should work