display data from database

Hello people, I need to display some fields from the database. My table name is Category. I’m using MySQL and i’ve already created the model, view and controller. my category model is as follows:

<?php

/**

  • This is the model class for table "category".

  • The followings are the available columns in table ‘category’:

  • @property integer $category_id

  • @property string $category_name

*/

class Category extends CActiveRecord

{

/**


 * Returns the static model of the specified AR class.


 * @return Category the static model class


 */


public static function model(&#036;className=__CLASS__)


{


	return parent::model(&#036;className);


}





/**


 * @return string the associated database table name


 */


public function tableName()


{


	return 'category';


}





/**


 * @return array validation rules for model attributes.


 */


public function rules()


{


	// NOTE: you should only define rules for those attributes that


	// will receive user inputs.


	return array(


		array('category_name', 'required'),


		array('category_name', 'length', 'max'=&gt;25),


		// The following rule is used by search().


		// Please remove those attributes that should not be searched.


		array('category_id, category_name', 'safe', 'on'=&gt;'search'),


	);


}





/**


 * @return array relational rules.


 */


public function relations()


{


	// NOTE: you may need to adjust the relation name and the related


	// class name for the relations automatically generated below.


	return array(


	);


}





/**


 * @return array customized attribute labels (name=&gt;label)


 */


public function attributeLabels()


{


	return array(


		'category_id' =&gt; 'Category',


		'category_name' =&gt; 'Category Name',


	);


}





/**


 * Retrieves a list of models based on the current search/filter conditions.


 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.


 */


public function search()


{


	// Warning: Please modify the following code to remove attributes that


	// should not be searched.





	&#036;criteria=new CDbCriteria;





	&#036;criteria-&gt;compare('category_id',&#036;this-&gt;category_id);


	&#036;criteria-&gt;compare('category_name',&#036;this-&gt;category_name,true);





	return new CActiveDataProvider(get_class(&#036;this), array(


		'criteria'=&gt;&#036;criteria,


	));


}

}

how can i display the field category_name in a the page views/index.php?

You can access to the field of a model as $model->fieldName.

I advice you to read the definitive guide to yii before going on, is a really good tutorial and will teach you almost all you have to know.

If you need further assistance, don’t exitate ask again!!