• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: Count registrations that meet a condition

Count registrations that meet a condition 4 years 11 months ago #40200

  • upbm
  • upbm's Avatar
  • OFFLINE
  • Junior Boarder
  • Posts: 34
  • Thank you received: 4
Hello,
I have a question that should be very simple for those who master the syntax, but I can't get out of it despite many attempts.
I have built a form to register for sports sessions which works very well. I added a field compte to count and display on the sheet the number of subscribers by adapting a script found on the forum.
In the default value of the field named compte I entered the following code:
//<code>
 $db = JFactory::getDbo();
 $db->setQuery("SELECT COUNT(`SubmissionId`) FROM #__rsform_submissions WHERE FormId='".$this->formId."'");
 $submissions = $db->loadResult();
 return  'Déjà inscrits : ' . $submissions;
//</code>

I would like to add a condition to count only registrations for a certain type of class. The text of different class is contains in a field name cours
I used SQL a long time ago and I want somthing like that:
SELECT COUNT SubmissionId FROM ...... WHERE FormId=.... AND cours = "Débutants"
where cours is the name of the field that contains text like "Débutants", or "Avancés"

Can you help me formulate this second part of the condition ?

Thanks
Didier
The administrator has disabled public write access.

Count registrations that meet a condition 4 years 9 months ago #40414

You could use the following code:
 
$cours = "Débutants"
$db = JFactory::getDbo();
$db->setQuery("SELECT COUNT(`SubmissionId`) FROM #__rsform_submission_values WHERE (FormId='".$this->formId. "'  AND FieldName='cours' AND FieldValue ='". $cours . "')");
$submissions = $db->loadResult();
 

Succes,
Ronald
The administrator has disabled public write access.

Count registrations that meet a condition 4 years 9 months ago #40416

  • upbm
  • upbm's Avatar
  • OFFLINE
  • Junior Boarder
  • Posts: 34
  • Thank you received: 4
Hello,
Thank you for your answer which I just tested and which works very well. The syntax elements that you bring to me will allow me to complete my work.
Thank you so much.
Didier.
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!