Hey guys,
I'm trying to use a MYSQL select query to look up the current user's rank (from a community builder table) and then create one of two dropdown elements.
Individually all the pieces appear to work;
- when I use my MYSQL select statement in a field element it outputs the correct values.
- when I manually change $result (i.e. not using the MYSQL query) it triggers the IF statement properly
- when I just use the output of the if statement it creates the menus correctly.
As such, I don't think I'm loading the correct $result into the IF statement; I've tried loads and loads of variations, but just can't see where I'm going wrong.
Can anyone help?
Thanks in advance,
Paul Hughes
I'm trying to use a MYSQL select query to look up the current user's rank (from a community builder table) and then create one of two dropdown elements.
Individually all the pieces appear to work;
- when I use my MYSQL select statement in a field element it outputs the correct values.
- when I manually change $result (i.e. not using the MYSQL query) it triggers the IF statement properly
- when I just use the output of the if statement it creates the menus correctly.
As such, I don't think I'm loading the correct $result into the IF statement; I've tried loads and loads of variations, but just can't see where I'm going wrong.
Can anyone help?
Thanks in advance,
Paul Hughes
Code:
$db =& JFactory::getDBO();
$query = "SELECT cb_rank FROM j16bpsa_comprofiler INNER JOIN j16bpsa_users ON j16bpsa_comprofiler.id=j16bpsa_users.id
WHERE (
`username` ='{$my->username}'
)
";
$db->setQuery($query);
$result = $db->loadResult();
if ($result == "GSM") {
$opts[] = JHTML::_('select.option', 'alpha', 'alpha');
$opts[] = JHTML::_('select.option', '2', 'two');
} else {
$opts[] = JHTML::_('select.option', 'beta', 'beta');
$opts[] = JHTML::_('select.option', '3', 'three');
}
return $opts;