• 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: Counter

Counter 10 years 9 months ago #23909

  • vlimper
  • vlimper's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 1
Dear all,

I'm tryting to add a counter in my RSForm registration, by using the code below in the defaul value field. When adding {counter:value} in the email text, there is no result.

The table in my MySQL data base is named jos_forme_data and the column name is id, like in below code. Anybody who can help me on this?

Thanks!

BR,
Vlimper

//<code>
$db = JFactory::getDbo();
$db->setQuery("SELECT COUNT(`id`) FROM jos_forme_data" WHERE form_id='".(int) $form_id."'");
return $db->loadResult()+1;
//</code>
The administrator has disabled public write access.

Counter 10 years 5 months ago #25428

  • seal305
  • seal305's Avatar
  • OFFLINE
  • Junior Boarder
  • Posts: 20
  • Thank you received: 1
I don't know if this code will work in the default value of all versions. Seems like in my Joomla 1.5 it did not work. I haven't checked the changelog in detail to figure it out.

I'd suggest putting it in the PHP Scripts under "Script called on form process" section something like this:
    $db = JFactory::getDbo();
    $db->setQuery("SELECT MAX(`SubmissionId`) FROM #__rsform_submissions WHERE FormId=3 ORDER BY `SubmissionId` LIMIT 1");
    $_POST['form']['counter'] = $db->loadResult()+1;

I used this code as a submission counter (to create an invoice number), but you can replace my query with yours. Like this: $db->setQuery("<QUERY HERE>");
Also, replace 'counter' in my code with with your field name. I would set the default value of the field to "0". Whatever you set: $_POST to is what will be saved in the database after the form processes.

Note FormId=3 in my code: you will need to form id to something right now in your code its just a variable name. And check if its form_id or FormId in your version- that is the field name and it will cause the query to cail if its not correct.
Last Edit: 10 years 5 months ago by seal305. Reason: code edit
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!