• 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: Auto Incimental Number

Auto Incimental Number 10 years 10 months ago #28055

  • colpc
  • colpc's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 12
Hey guys,
ON a form, I need to have the system place a Auto Incremental number
( 3 digits) on each and eery submit.

Can you advise on the best way to do this.

Thank you
The administrator has disabled public write access.

Auto Incimental Number 10 years 10 months ago #28064

  • cosmin.cristea
  • cosmin.cristea's Avatar
  • OFFLINE
  • Platinum Boarder
  • Posts: 756
  • Thank you received: 144
You can try generating a 3 digit number, based on a submission counter.
Before creating the PHP Script, a hidden field must be created (we will store the value in it, in this example we name it "hidden")

Please note that his has some limitations and is not given as a solution but more of an example to build on:
//Connect to the database
$db = JFactory::getDbo();
 
//Create a simple counter
$db->setQuery("SELECT COUNT(`SubmissionId`) FROM #__rsform_submissions WHERE `FormId`='".(int) $formId."'");
$submissions = $db->loadResult() +1;
 
//Insert the result in the hidden field and format it to be 3 characters long,adding 0 to the left of the string (e.g. first number will be 001)
$_POST['form']['hidden'] = str_pad($submissions, 3, "0", STR_PAD_LEFT);
My help is not official customer support. To receive your support, submit a ticket by clicking here
Last Edit: 10 years 9 months ago by cosmin.cristea.
The administrator has disabled public write access.
The following user(s) said Thank You: g7website

Auto Incimental Number 10 years 3 months ago #30352

cosmin.cristea wrote:
You can try generating a 3 digit number, based on a submission counter.
Before creating the PHP Script, a hidden field must be created (we will store the value in it, in this example we name it "hidden")

Please note that his has some limitations and is not given as a solution but more of an example to build on:
//Connect to the database
$db = JFactory::getDbo();
 
//Create a simple counter
$db->setQuery("SELECT COUNT(`SubmissionId`) FROM #__rsform_submissions WHERE `FormId`='".(int) $formId."'");
$submissions = $db->loadResult() +1;
 
//Insert the result in the hidden field and format it to be 3 characters long,adding 0 to the left of the string (e.g. first number will be 001)
$_POST['form']['hidden'] = str_pad($submissions, 3, "0", STR_PAD_LEFT);

Do I put these codes in the default value in hidden field? Right?
The administrator has disabled public write access.

Auto Incimental Number 10 years 3 months ago #30354

  • cosmin.cristea
  • cosmin.cristea's Avatar
  • OFFLINE
  • Platinum Boarder
  • Posts: 756
  • Thank you received: 144
No, that particular script needs to be added in the PHP scripts called on form process. More information can be found here:

http://www.rsjoomla.com/support/documentation/view-article/602-php-scripts.html
My help is not official customer support. To receive your support, submit a ticket by clicking here
The administrator has disabled public write access.
The following user(s) said Thank You: g7website
  • 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!