• 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: using database to populate form using customscript

using database to populate form using customscript 13 years 4 months ago #12262

Hiya,
I am new to RS Forms (and not a very good programmer) and am using it to create a site form my final year project at uni. I need to pull back data that is stored in the database (category name) into the front end form in a drop down. The user should then select the category they want and then the description that is also stored in the database needs to be displayed.

The form labels are:
cat_nme are displaying the dropbown of the category name
cat_desc for the category description that will be displayed in a text box once the category has been selected

The database fields are:
Category_Name
Category_Description

I've read many posts and tried code that has been suggested, but am not getting anywhere. Nothing is being pulled from the database and keep getting errors. I've included the code i've been working with below which is what I have seen suggested in the user guides.

Thank you to anyone who can help, I am truly lost
Laura


$items = "|Please Select[c]\n";
$db =& JFactory::getDBO();
$db->setQuery("SELECT `Category_Name` FROM `jos_capacity_categories");
$result = $db->loadObjectList();

foreach ($result as $r)
$items .= $r->Category_Name"\n";

return $items;
Last Edit: 13 years 4 months ago by lmcennerney.
The administrator has disabled public write access.

Re:using database to populate form using customscript 13 years 4 months ago #12273

  • alexp
  • alexp's Avatar
  • OFFLINE
  • RSJoomla! Official Staff
  • Posts: 2253
  • Thank you received: 180
Hello,

Try this instead:
//<code>
$items = "|Please Select[c]\\n";
$db = JFactory::getDBO();
$db->setQuery("SELECT `Category_Name` FROM #__capacity_categories");
$result = $db->loadObjectList();
foreach ($result as $r)
$items .= $r->Category_Name"\\n"; 
return trim($items);
//</code>
Please note: my help is not official customer support. To receive your support, submit a ticket by clicking here
Regards,
RSJoomla! Development Team
Last Edit: 13 years 4 months ago by alexp.
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!