function ff_databaseToSelect($st, $tbl, $lbl, $val, $sql)
{
	$db = JFactory::getDBO();	//Get Database Object
	global $ff_processor;

	//Create your own query here
	if($sql and $sql!=''){
		$db->setQuery($sql);
	}else{
		$db->setQuery("SELECT $lbl, $val FROM $tbl");
	}
	

	$result = $db->loadObjectList(); //load the result from the query
	$values = [];
	foreach($result as $rrow){
		$values[]=(object)array('selected'=>0,'label'=>$rrow->{$lbl}, 'value'=>$rrow->{$val});
	}
	
	unset($rrow);
	
	foreach($ff_processor->rows as $row)
	{
		if ($row->name==$st){
			$row->selectList = $values;
			foreach($values as $var){
				$row->data2 .= $var->selected.";".$var->label.";".$var->value."\n";
			}
			break;
		}
		unset($row);
	}
}