Skip to main content
Tweeted twitter.com/StackDrupal/status/750329466275172352
added 23 characters in body; edited title
Source Link
Pierre.Vriens
  • 36k
  • 40
  • 50
  • 182

How to programmatically display a select list label instead of the value programmatically?

I created a select list box in the following format

Gender
1|Male
2|Female

Gender
1|Male
2|Female

I want to display the follwing information in a table but I am getting "1" for male and "2" for female.

hereHere is my code:

function display_results_submissions(){
$results = db_query("SELECT * FROM {users}");
$header = array( t('Name'), t('Mail'), t('Gender'),);

foreach($results as $result){
        $rows[] = array(
            
            $result->name,
            $result->mail,
            $result->gender,
                
            );
    }

    return theme('table', array('header' => $header, 'rows'=>$rows));
}

I want to display Male or Female instead of "1" and "2". How can I do so?

How to display a select list label instead of the value programmatically

I created a select list box in the following format

Gender
1|Male
2|Female

I want to display the follwing information in a table but I am getting "1" for male and "2" for female.

here is my code

function display_results_submissions(){
$results = db_query("SELECT * FROM {users}");
$header = array( t('Name'), t('Mail'), t('Gender'),);

foreach($results as $result){
        $rows[] = array(
            
            $result->name,
            $result->mail,
            $result->gender,
                
            );
    }

    return theme('table', array('header' => $header, 'rows'=>$rows));
}

I want to display Male or Female instead of "1" and "2"

How to programmatically display a select list label instead of the value?

I created a select list box in the following format

Gender
1|Male
2|Female

I want to display the follwing information in a table but I am getting "1" for male and "2" for female.

Here is my code:

function display_results_submissions(){
$results = db_query("SELECT * FROM {users}");
$header = array( t('Name'), t('Mail'), t('Gender'),);

foreach($results as $result){
        $rows[] = array(
            
            $result->name,
            $result->mail,
            $result->gender,
                
            );
    }

    return theme('table', array('header' => $header, 'rows'=>$rows));
}

I want to display Male or Female instead of "1" and "2". How can I do so?

Source Link
Ian Nato
  • 207
  • 1
  • 3
  • 7

How to display a select list label instead of the value programmatically

I created a select list box in the following format

Gender
1|Male
2|Female

I want to display the follwing information in a table but I am getting "1" for male and "2" for female.

here is my code

function display_results_submissions(){
$results = db_query("SELECT * FROM {users}");
$header = array( t('Name'), t('Mail'), t('Gender'),);

foreach($results as $result){
        $rows[] = array(
            
            $result->name,
            $result->mail,
            $result->gender,
                
            );
    }

    return theme('table', array('header' => $header, 'rows'=>$rows));
}

I want to display Male or Female instead of "1" and "2"