Limited number of submission

jejmule 07 Jan, 2011
Hello,

I set up a form for an event. Every thing work fine.

I like to have only 50 inscription and after display a message : "sorry inscription are full"
How i can do this? My idea was to read "cf_id" in my table and if cf_id >= 50 then display message.

to do i need to modify my html form and include php code. Do you have example to connect database, i have no experience with.

There are other way to do this?

regards,
GreyHead 08 Jan, 2011
Hi jejule,

Sorry, I missed this post yesterday.

You could use cf_id but it's a bit unreliable. If an entry is deleted or damaged your count would bo inaccurate. Better to use SQL to do the count for you by adding code like this to the Form HTML
<?php
$db =& JFactory::getDBO();
$query = "
    SELECT COUNT(*)
        FROM `#__my_table_name` ;
";
$db->setQuery($query);
$count = $db->loadResult();
if ( $count > 50 ) {
  echo "Sorry this event is full";
} else {
?>
<!-- add your Form HTML here -->
<?php
}
?>

Bob
This topic is locked and no more replies can be posted.