I am missing something here, but I am not sure what it is. The question is, how do I load a table into a selection box in a form. Here is what I have:

$form['tournament_add']['tourney_league'] = array(
'#type' => 'select',
'#title' => t('League Name'),
'#default_value' => variable_get('poker_leagues', array()),
'#options' => $select,
'#extra' => '',
'multiple' => 1 );

I am pulling poker_leagues into a selection box, but I think the problem may have to do with the fact that there are multiple fields in the table. How do I get this to work? Is there some setup code that has to come before this?

Thanks in advance.

Norm

Comments

npollock’s picture

Ok, I have played with this some more and now have the following code:

$sql = 'SELECT p.name FROM {poker_leagues} p WHERE p.id != 0';
$form['tournament_add']['tourney_league'] = array(
'#type' => 'select',
'#title' => t('League Name'),
'#options' => $sql
);

Here is my latest code. This still doesn't work, but I don't understand why. I am putting the names of the poker leagues in $sql, then using $sql for the options. Can anyone tell me why this isn't working?

Thanks

Norm