Forums

Drop down with the db date

federcla 25 Oct, 2012
HI,
sorry but i don't understand if is possible do a options list in a drop-down with the date of a db

I can use the drop-down element or i must use Custom Element and i must write the code?

thanks
federcla 24 Jul, 2013
Hi Bob,
I read your guide, but I figured if I can do one thing

I need to fill a drop down with data from the db

I put in section action a Custom Code before Show html, inside the Custom Code I make a query that returns 2 values​​, id and description

$query = "SELECT id,description FROM app_costi WHERE anno=2013 ORDER BY id ASC ";
$db->setQuery($query);
$prova = $db->loadRowList();


now $prova is an multidimensional array

can I now insert $prova in $form->data[] for use with dynamic drop down?

I had thought of doing so

foreach ($prova as $test) {}

$form->data['prova'] = $test;


but I have not figured out how to use the dynamic system

what I put in Data Path? and in Value Key? and in Text Key?

tks bob
GreyHead 24 Jul, 2013
Hi bob,

I had some code to do this but have edited it out :-(

I would use $db->loadAssocList(); instead of loadRowList() and then you should be able to use
$form->data['prova']= $db->loadAssocList();
and use 'id' and 'description' for the value and text entries on the Dynamic Data tab.

Bob
federcla 02 Aug, 2013
great, it work

thanks Bob
This topic is locked and no more replies can be posted.