• 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: Load values from submission table for one user

Load values from submission table for one user 6 years 9 months ago #37052

  • cjmicro
  • cjmicro's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 15
  • Thank you received: 5
We have a form where people submit horses for a show entry. First the trainer enters their info in one form. Then they log in and enter horses, now we need a 3rd form for their final entry.

We need to populate a dropdown on another form with that person's horses, so they can choose a horse.

I have the code working to retrieve the horses' names, but it retrieves ALL of them. How can i adjust this to retrieve only the logged in user's horses names to populate that dropdown? The rsform_submission_values table does not have userid as a column so i can't match it up there.

Here is what i have so far (which is in the dropdown field items area)

//<code>
//Load the user
$user = JFactory::getUser();
$db = JFactory::getDbo();
$userId = $user->get('id');

// Is the user logged in?
if ($userId) {

// Does the User have a submission
$db->setQuery("SELECT `SubmissionId` FROM `#__rsform_submissions` WHERE `FormId` = '53' AND `UserId`='".$userId."'");
$submissionId = $db->loadResult();

//If so, grab the value of first_name field
If ($submissionId) {
$items = array();

$items = "|Please Select[c]\n";
$db->setQuery("SELECT FieldValue FROM #__rsform_submission_values WHERE FormId = '53' AND FieldName = 'jc_name' ");
$results = $db->loadObjectList();
foreach ($results as $r)
$items .= $r->FieldValue . "\n";

return $items;
} // if submissionid
return "There is no horse application on file for you. Please make sure you are logged in. If you still have trouble, contact our office.";
} // if user
return "There is no trainer application on file for you. Please make sure you are logged in. If you still have trouble, contact our office.";

//</code>
The administrator has disabled public write access.

Load values from submission table for one user 6 years 9 months ago #37072

  • cjmicro
  • cjmicro's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 15
  • Thank you received: 5
Got this figured out. Here is the code, in case it helps someone else. Not sure the error messages work but the dropdown selection does. Now to figure out how to get it to return other values from that submission based on drop down choice. Any ideas?

//<code>
//Load the user
$user = JFactory::getUser();
$db = JFactory::getDbo();
$userId = $user->get('id');

// Is the user logged in?
if ($userId) {

// Does the User have a submission
$db->setQuery("SELECT `SubmissionId` FROM `#__rsform_submissions` WHERE `FormId` = '53' AND `UserId`='".$userId."' ");
$submissionId = $db->loadResult();

//If so, grab the values of jc_name field
If ($submissionId) {
$items = array();

$items = "|Please Select[c]\n";
$db->setQuery("SELECT FieldValue FROM #__rsform_submission_values LEFT JOIN #__rsform_submissions
ON #__rsform_submission_values.SubmissionId=#__rsform_submissions.SubmissionId WHERE `UserId`='".$userId."' AND FieldName = 'jc_name'");
$results = $db->loadObjectList();
foreach ($results as $r)
$items .= $r->FieldValue . "\n";
return $items;
} //if submissionid
return "There is no horse application on file for you. Please make sure you are logged in. If you still have trouble, contact our office.";
} //if user
return "There is no trainer application on file for you. Please make sure you are logged in. If you still have trouble, contact our office.";

//</code>
The administrator has disabled public write access.
The following user(s) said Thank You: Specialist, johnnyboi_123, cbrock
  • 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!