• 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: Want to use Joomla UserID in WHERE Clause of Query

Want to use Joomla UserID in WHERE Clause of Query 11 years 4 months ago #25960

  • sdsi
  • sdsi's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 8
Hi all - I am using the following code to get the Joomla user ID of the logged-in user:

//<code>
$user = JFactory::getUser();
return $user->get('id');
//</code>

Say the returned value is 999. Now I would like to do is have a dropdown in the form that is populated using a list created by the following:
//<code>
$items = "|Please Select[c]\n";
$db =& JFactory::getDBO();
$db->setQuery("SELECT id, name FROM #__x WHERE x=999");
$result = $db->loadObjectList();
foreach ($result as $r)
      $items .= $r->id . '|' . $r->name . "\n";
return $items;
//</code>

The above works just fine; however, I know the logged-in user will not always be ID 999. How can I change this so the value assigned from the first query is assigned to a variable which can be used in the WHERE clause?
Last Edit: 11 years 4 months ago by sdsi. Reason: Typo
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!