• 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: Getting certain field value based on sql drop list

Getting certain field value based on sql drop list 3 years 1 month ago #41902

  • tamimi5
  • tamimi5's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
Dear RSform community,

I hope everyone is well, can anyone point me to how to achieve this .. as my head is spinning for hours without any good results lol

I have a 2 form one like incident creation which has few fields - the user will fill it and submit it

the second form will take the name of the incident from the first form using sql like this one I found on tutorials which works as I wanted

//<code>
// Prepare the empty array
$items = array();
// Prepare the database connection
$db = JFactory::getDbo();
// Keep this if you'd like a "Please select" option, otherwise comment or remove it
$items[] = "|Please Select[c]";

// Run the SQL query and store it in $results
$db->setQuery("SELECT FieldValue FROM `josh2_rsform_submission_values` WHERE `FormId` = 15 AND `FieldName` = 'incident' ORDER BY `josh2_rsform_submission_values`.`SubmissionValueId` DESC");
$results = $db->loadObjectList();

// Now, we need to convert the results into a readable RSForm! Pro format.
// The Items field will accept values in this format:
// value-to-be-stored|value-to-be-shown
// Eg. m|M-sized T-shirt
foreach ($results as $result) {
$value = $result->FieldValue;
$label = $result->FieldValue;
$items[] = $value.'|'.$label;
}

// Multiple values are separated by new lines, so we need to do this now
$items = implode("\n", $items);

// Now we need to return the value to the field
return $items;
//</code>

However this will should only the incident name which is fine, what if I wanted to show another field value based on the selection of the dropdown list ? is that possible ? or is it possible to have 2 field value shown that has the same submission ID ?
cause I want to show the date of submission(which is already assigned to a field in the first form) along with the incident name

Thank you in advance for kind guidance and support
The administrator has disabled public write access.

Getting certain field value based on sql drop list 3 years 1 month ago #41903

  • tamimi5
  • tamimi5's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
tamimi5 wrote:
Dear RSform community,

I hope everyone is well, can anyone point me to how to achieve this .. as my head is spinning for hours without any good results lol

I have a 2 form one like incident creation which has few fields - the user will fill it and submit it

the second form will take the name of the incident from the first form using sql like this one I found on tutorials which works as I wanted

//<code>
// Prepare the empty array
$items = array();
// Prepare the database connection
$db = JFactory::getDbo();
// Keep this if you'd like a "Please select" option, otherwise comment or remove it
$items[] = "|Please Select[c]";

// Run the SQL query and store it in $results
$db->setQuery("SELECT FieldValue FROM `josh2_rsform_submission_values` WHERE `FormId` = 15 AND `FieldName` = 'incident' ORDER BY `josh2_rsform_submission_values`.`SubmissionValueId` DESC");
$results = $db->loadObjectList();

// Now, we need to convert the results into a readable RSForm! Pro format.
// The Items field will accept values in this format:
// value-to-be-stored|value-to-be-shown
// Eg. m|M-sized T-shirt
foreach ($results as $result) {
$value = $result->FieldValue;
$label = $result->FieldValue;
$items[] = $value.'|'.$label;
}

// Multiple values are separated by new lines, so we need to do this now
$items = implode("\n", $items);

// Now we need to return the value to the field
return $items;
//</code>

However this will should only the incident name which is fine, what if I wanted to show another field value based on the selection of the dropdown list ? is that possible ? or is it possible to have 2 field value shown that has the same submission ID ?
cause I want to show the date of submission(which is already assigned to a field in the first form) along with the incident name

Thank you in advance for kind guidance and support

Ok I managed to get the results I need with SQL but I have no idea how to alter the results part to be shown on rsform dropdown menu

the sql statement that I used

$db->setQuery("SELECT SubmissionId ,GROUP_CONCAT(FieldValue ORDER BY SubmissionValueId) FROM josh2_rsform_submission_values WHERE FieldName IN('incident','subdateeoc001') AND `FormId` = 15 GROUP BY SubmissionId ORDER BY `josh2_rsform_submission_values`.`SubmissionValueId` DESC");

can anyone help me with getting the results of this query to show on my rsform field ?
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!