Drop down eval population syntax help

dealio

Member
I followed this link to populate a drop down however i get error
http://fabrikar.com/forums/index.php?wiki/dropdown-element/








I have==============

$options[] = JHTML::_('select.option','1','select');
$options = array();
$query = 'SELECT id, order_id FROM xoms_mgls';
$db->setQuery($query);
$rows = $db -> loadObjectList();
foreach ($rows as $row) {
$options[] = JHTML::_('select.option',$row->id, $row->order_id);
}

return $options;
======================


Error
======================
Fatal error: Call to a member function setQuery() on a non-object in /home/site/public_html/components/com_fabrik/models/element.php(3563) : eval()'d code on line 4


$db->setQuery($query);


thanks
 
Has $db been initiliazed???
$db = JFactory::getDbo();

Also you're resetting $options to a blank array with the line...
$options = array();
That line should be on top.

Also...
$options[] = JHTML::_('select.option','1','select');
would return the same value as if you selected from the list where $row->id == '1'
I'd change that initial select to
$options[] = JHTML::_('select.option','0','select');
or
$options[] = JHTML::_('select.option','','select');
 
Thanks that works.





$db = JFactory::getDbo();
$options = array();
//$options[] = JHTML::_('select.option','0','select');

$query = 'SELECT id, order_id FROM xoms_mgls';
$db->setQuery($query);
$rows = $db -> loadObjectList();

foreach ($rows as $row) {

$options[] = JHTML::_('select.option',$row->id, $row->order_id);

}

return $options;
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top