Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8575083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:36:59+00:00 2026-06-11T19:36:59+00:00

How to select a column of data from table with WHERE closure and list

  • 0

How to select a column of data from table with WHERE closure and list as combo-box in yii?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T19:37:00+00:00Added an answer on June 11, 2026 at 7:37 pm

    Have a look at the CHtml methods dropDownList() and activeDropDownList().

    You can set the data you insert into the dropdownlist to be the results from an active record query, for example;

    echo CHtml::dropDownList('myDropdown', '1',  CHtml::listData(myModel::model()->findAllByAttributes(array('myField'=>1)),'id','name'));
    

    The above command would select all the results from the myModel model where myField = 1 (using their ‘id’ as the value and their ‘name’ as the displayed text) and insert them into a dropdownlist with name ‘myDropdown’ and the initial selected value would be 1.

    If you’re using this in a form, for example created by gii, then you can use the $form to create the dropdown. This actually uses activeDropDownList(), so the syntax is a little different, here’s an example:

     echo $form->dropDownList($model,'myOtherField', CHtml::listData(myModel::model()->findAllByAttributes(array('myField'=>1)),'id','name'));
    

    the bit that’s actually populating the dropdownlist with the data from the active record query is the CHtml::listData() method which is taking a result set from the active record query and formatting it into an array that will be accepted into the $data param in dropDownList() or activeDropDownList().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm try display data from column points , SELECT * from table ORDER by
I have a table that I select data from with a column called parent
here are my data from table Companies column cName CK'Wang Pte Ltd Chong Wang
I am doing a very simple select from a table like SELECT column FROM
I have encountered a problem when trying to select data from a table in
So I have the following: SELECT data, encrypteddata, CONVERT(varchar, DecryptByKey(encrypteddata)) AS 'decrypteddata' FROM table
I'm trying to select data from a table defined similar to the following :
I am trying to select some data in the following manner: SELECT column FROM
Put simply, I want to select all data in two columns from each of
I am trying to select a column from an IEnumerable collection that has a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.