I have a group that wants a field to be automatically removed from the form once a certain number of people have signed up for that particular time/activities slot. I have been searching everywhere for how to do this in a form and in chronoforms. Can anyone help me in how to set a limit to a particular field (ie 5 people can chose and then it is no long a choice)?
THanks.
Hi terrihallwd,
You can do this in the Form HTML - add a MySQL query to count the number of sign-ups and don't show the field if the number is five or more.
Bob
Thank you. I don't know how to do that...so guess I'm going to have to go do some research. Thanks for giving me a place to start looking.
Hi terrihallwd,
How are you setting up the 'record keeping' part of this application? Presumably you have a database table? What are the relevant column names?
Bob
I have the data being collected in a database.
A few of the column names are:
welcometable1
welcometable2
welcometable3
welcometable4
welcometable5
shepherds1
shepherds2
shepherds3
shepherds4
shepherds5
These correspond with the Job and the time slots given. Welcome table - each time slot needs 3. Shepherds - each time slot needs 20.
Hi mugen,
Yes, but I'm not sure that it will help you. Check the MySQL docs to build the WHERE clause that you need (you may not need one at all).
Bob
Hi Bob
Thanks for your help
here is my code, it´s not changing if cf_id is higher than 10
If i change to,
if ( $result>= 0 ) {
it change the result to "// show form html " as i want
if i look in the database "0" come from field "cf_user_id"
it should lock in field cf_id instead
can you give me some advice
<?php
$db =& JFactory::getDBO();
$query = "
SELECT COUNT(*)
FROM ".$db->nameQuote('#__XXXXXXX')."
WHERE ".$db->nameQuote('cf_id')." = ".$db->quote($value).";
";
$db->setQuery($query);
$count = $db->loadResult();
if ( $result>= 10 ) {
?>
// show form html
<?php
} else {
?>
<p>Sorry no places left</p>
<?php
}
?>