Create capacity limitation for each Item in dropdown

Links for php scripts

Moderators: macek, egami, gesf

kareez55
New php-forum User
New php-forum User
Posts: 1
Joined: Tue Aug 05, 2014 10:33 am

Create capacity limitation for each Item in dropdown

Postby kareez55 » Tue Aug 05, 2014 10:45 am

Hello
I created a form and use this php code for create limitation registration in form:


Code: Select all

$max = 1;
$user = JFactory::getUser();
$db   = JFactory::getDbo();
$query   = $db->getQuery(true);
$query->select('COUNT('.$db->qn('Username').')')
    ->from($db->qn('#__rsform_submissions'))
    ->where($db->qn('FormId').'='.$db->q($formId))
    ->where($db->qn('Username').'='.$db->q($user->get('username')));
$db->setQuery($query);
$counter = $db->loadResult();
if ($counter >= $max){
  $formLayout = '<p style="color:red;">Sorry, you have reached the maximum number of submissions for this form.</p>';
}
 
global $database;
$database = JFactory::getDBO();
$database->setQuery("SELECT COUNT(`SubmissionId`) FROM #__rsform_submissions WHERE `formId`='25'");
$database->query();
if (intval($database->loadResult()) >= 33)
{
echo 'Dear user, Limitation of this group is full. Please try other Groups.';
$formLayout = '';
}


It work very exact.
But I have a dropdown list in this form. This php code just control limitation for all Item of dropdown list.
I need limitation for each item of dropdown in one form.
Example:
Group1
Group2
Group3

Registration capacity for item 1 is 33 user.
Registration capacity for item 2 is 23 user.
Registration capacity for item 3 is 13 user.

Each user just can fill this form for one time.

Form image is attached.
Please guide me.
Attachments
View.jpg
View.jpg (17.17 KiB) Viewed 97 times

Return to “PHP Scripts”

Who is online

Users browsing this forum: No registered users and 1 guest