• 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: Get address from jos_contact_details in Joomla 2.5

Get address from jos_contact_details in Joomla 2.5 11 years 2 months ago #26574

  • Roberts
  • Roberts's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 54
  • Thank you received: 1
I have tried all sorts to retrieve data from jos_contact_details without any success at all.

I am using the following sql in the Default Value of a text area to auto populate the text area

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

// Is the user logged in?
if ($userId) {
// Grab the value from the database.
$db->setQuery("SELECT `address` FROM `jos_contact_details`");
return $db->loadResult();
}
//</code>


But for some reason it does not work!

Any ideas greatly appreciated
The administrator has disabled public write access.

Get address from jos_contact_details in Joomla 2.5 11 years 2 months ago #26577

  • Roberts
  • Roberts's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 54
  • Thank you received: 1
Okay ...Don't all rush!

I found it -


//<code>
$items = array();
$db = JFactory::getDbo();

$db->setQuery("SELECT name, address FROM #__contact_details");

$results = $db->loadObjectList();
foreach ($results as $result){
$value = $result->address;
$label = $result->name;
$items[] = $value;

}
$items = implode("\n", $items);
return $items;
//</code>


This returns all names and addresses from the jos_contacts_details table in Joomla 2.5

What I need to do now is to filter the results from an option selected in a drop down box

To put it crudely ...WHERE `names`= {selected:value} of a dropdown list


Any thoughts / ideas?
Last Edit: 11 years 2 months ago by Roberts.
The administrator has disabled public write access.

Get address from jos_contact_details in Joomla 2.5 11 years 2 months ago #26581

  • djseleco
  • djseleco's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 47
  • Thank you received: 10
Hi, i'm not expert but i think that this is the right code for you

//<code>
$items = array();
$db = JFactory::getDbo();
$items[] = "|Please Select[c]";
 
$db->setQuery("SELECT name, address FROM #__contact_details");
$results = $db->loadObjectList();
 
foreach ($results as $result) {
  $value = $result->address;
  $label = $result->name;
  $items[] = $value.'|'.$label;
}
$items = implode("\n", $items);
 
return $items;
//</code>
The administrator has disabled public write access.

Get address from jos_contact_details in Joomla 2.5 11 years 2 months ago #26582

  • djseleco
  • djseleco's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 47
  • Thank you received: 10
ops sorry I didn't read your last post
The administrator has disabled public write access.

Get address from jos_contact_details in Joomla 2.5 11 years 2 months ago #26588

  • Roberts
  • Roberts's Avatar
  • OFFLINE
  • Senior Boarder
  • Posts: 54
  • Thank you received: 1
Hey, no worries DJ

Thanks for trying ;)
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!