• 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: preload data from sql to dropdown

preload data from sql to dropdown 10 years 10 months ago #27927

  • prusser
  • prusser's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
Hello!
I need load several fields (id, name) from database to dropdown box in display( duration load form) Please help. my code:
$db_table_to_show = 'es_client';

$connect_to_db = mysql_connect($db_host, $db_username, $db_password)
or die("Could not connect: " . mysql_error());

mysql_select_db($db_name, $connect_to_db)
or die("Could not select DB: " . mysql_error());

foreach($fields as $i=>$field){
if($field->name=='es_client'){
$database->setQuery("SELECT id as val, name as txt FROM es_client");
$values = $database->loadObjectList();
$default_value = array();
foreach($values as $row){
$default_value[]= $row->val.'|'.$row->txt;
}
$default_value = implode(',',$default_value);
$fields[$i]->default_value = $default_value;
}
}

mysql_close($connect_to_db);
probably its wrong...
I'm new user in joomla so explain
The administrator has disabled public write access.

preload data from sql to dropdown 10 years 10 months ago #27933

  • cosmin.cristea
  • cosmin.cristea's Avatar
  • OFFLINE
  • Platinum Boarder
  • Posts: 756
  • Thank you received: 144
An example on this topic can be found in the following article
http://www.rsjoomla.com/support/documentation/view-article/94-auto-populate-a-list-from-a-table.html
it might not suit your needs but you can further customize it for your specific scenario.
My help is not official customer support. To receive your support, submit a ticket by clicking here
The administrator has disabled public write access.
The following user(s) said Thank You: prusser

preload data from sql to dropdown 10 years 10 months ago #27937

  • prusser
  • prusser's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 2
Done! Thank you!
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!