• 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: Drop down with my Community Builder connections

Drop down with my Community Builder connections 12 years 8 months ago #14543

  • dethierp
  • dethierp's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 6
  • Thank you received: 1
Hi,

I am trying to create a drop down list with the community builder user's connections.

So far I wrote the following code in the dropdown items which shows all CB users first name and last name and stores their user_id.
 
//<code>
$items = "|Please Select[c]\n";
$db =& JFactory::getDBO();
$db->setQuery("SELECT user_id,firstname, lastname FROM jos_comprofiler");
$result = $db->loadObjectList();
 
foreach ($result as $r)
$items .= $r->user_id. '|' . $r->firstname." " . $r-> lastname."\n";
 
return ($items);
// </code>
 

Now I would like to add to the select query an additional criteria which would make the dropdown only return the users' connections. Something which would say this:

Get CB user ID:
$my = & JFactory::getUser();
$db = JFactory::getDBO();
$myid = $my->id;

Only select my CB connections:
SELECT user_id,firstname, lastname FROM jos_comprofiler WHERE referenceid ='".$myid."' AND accepted = 1 (in the jos_comprofiler_member table)

The section where I'm stuck is the "WHERE" part...

I'm stuck for days on this so I'm desperately looking for help.

Thanks

Philippe
php/sql beginner
Last Edit: 12 years 8 months ago by dethierp. Reason: more clear in request
The administrator has disabled public write access.

Re: Drop down with my Community Builder connections 12 years 6 months ago #15300

  • dethierp
  • dethierp's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 6
  • Thank you received: 1
I finaly managed to get this working using the following code:
$my = & JFactory::getUser();
$db = JFactory::getDBO(); 
$myid = $my->id;
if ($myid > 0)
{
$db->setQuery("SELECT firstname FROM jos_comprofiler WHERE user_id='".$myid."' LIMIT 1");
$myfirstname= $db->loadResult();
$db->setQuery("SELECT lastname FROM jos_comprofiler WHERE user_id='".$myid."' LIMIT 1");
$mylastname= $db->loadResult();
 
}
 
 
$items .= $myid. "|" . $myfirstname . " " . $mylastname . "\n" ; 
 
 
 
$db2 =& JFactory::getDBO(); 
$db2->setQuery("
SELECT memberid FROM jos_comprofiler_members WHERE referenceid ='".$myid."' AND accepted = 1");
$result = $db2->loadObjectList(); 
foreach ($result as $r) 
{
 
 
$db3 =& JFactory::getDBO();
$db3->setQuery("SELECT firstname FROM jos_comprofiler WHERE user_id= '".$r->memberid."'");
$firstname= $db3->loadResult();
$db3->setQuery("SELECT lastname FROM jos_comprofiler WHERE user_id= '".$r->memberid."'");
$lastname= $db3->loadResult();
 
$items .= $r->memberid . "|" . $firstname . " " . $lastname . "\n" ; 
}
return $items; 
 
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!