• 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: hidden flield to get data from database

hidden flield to get data from database 13 years 11 months ago #13590

Hi

I have got a foolowing script that I found here which should grab relevant data and insert in into a hidden field that I have created. Unfortunatelly I cannot get it working. Can somebody help? Thanks a mill. Dan

//<code>
global $database, $my;//global declaration
$mydata = $my->id;//fetching the user id who has logged in

if($mydata!=0)
{
$data = mysql_query("SELECT * FROM jos_table WHERE id = '".$my->id."'")or die(mysql_error())
;//this query will fetch you the record of that particular user
while($info = mysql_fetch_array( $data ))
{
return $info;//return the name of the user which will be populated in the text filed
}
}
else
{
return 'no record';
}
//</code>

It gives me that no record found
The administrator has disabled public write access.

Re: hidden flield to get data from database 13 years 5 months ago #15399

  • servicefly
  • servicefly's Avatar
  • OFFLINE
  • Junior Boarder
  • Posts: 22
  • Thank you received: 1
Did you find the answer? I too am looking to populate a hidden field from the database. My problem might be slightly different as I am trying to populate a hidden field with the "SubmissionId" from the _rsform_submission_values table when it matches a name from a form.
The administrator has disabled public write access.

Re: hidden flield to get data from database 13 years 5 months ago #15400

You should go here (docs.joomla.org/How_to_use_the_database_classes_in_your_script) and read about joomla! database classes. It will make your life a little easier.

To get the user id try this

$user = &JFactory::getUser();
$uid = $user->get('id');
The administrator has disabled public write access.

Re: hidden flield to get data from database 13 years 4 months ago #15707

I use the following to connect to the database.
$db =& JFactory::getDBO();
$db->setQuery("QUERY");
Regards
Wilco Alsemgeest

Please note: my help is not official customer support. To receive your support, submit a ticket by clicking www.rsjoomla.com/my-support-tickets.html
The administrator has disabled public write access.

Re: hidden flield to get data from database 13 years 4 months ago #15709

  • webcat-solutions
  • webcat-solutions's Avatar
  • OFFLINE
  • Junior Boarder
  • Dutch Joomla specialist
  • Posts: 29
  • Thank you received: 4
What kind of information are you trying to retreive? Is it user account related or something else?
The administrator has disabled public write access.

Re: hidden flield to get data from database 12 years 9 months ago #18282

  • servicefly
  • servicefly's Avatar
  • OFFLINE
  • Junior Boarder
  • Posts: 22
  • Thank you received: 1
Found solution to prefill hidden field (or text field) from DB.

Place this in Default Value:
//<code>
$db =& JFactory::getDBO();
{
$db->setQuery('SELECT column_label FROM #__dbextlabel WHERE column_label>"0"');
$variablename1 = $db->loadResult();
}
return $variablename1;
//</code>

here is how to correct/customize it for your need:

column_label = column (sometimes called field) of the record in your DB table.
dbtextlabel = This is the table in your DB...!keep the #__! add this to the end of it with no spaces.
$variablename1 = you make up a variable name here...!has to have "$" in the front like above!

I hope this really helps the non-programmers!
The administrator has disabled public write access.
The following user(s) said Thank You: migors
  • 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!