Yii Framework Forum: Showing Selected Name In Drop Down While Updating - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Showing Selected Name In Drop Down While Updating Rate Topic: -----

#1 User is offline   developer! 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 110
  • Joined: 28-November 12

Posted 25 January 2013 - 06:16 AM

Hi Experts,

I'm able to show all the names in drop down while creating a record.. how can show same dropdown value while updating..


Many Thanks,
0

#2 User is offline   karthik123 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 23
  • Joined: 23-November 12
  • Location:Tamilnadu,coimbatore,India

Posted 25 January 2013 - 06:44 AM

Hoping to help this code for your problem
Do like that Model

public function selectStudentName()
{
$connection = yii::app()->db1;

$sql="Select Sid,StudentName from tbl_student";

$command=$connection->createCommand($sql);
$students = $command->queryAll();

$studList = $this->getDropdownList($students,'Sid','StudentName');

return $studList;


}

function getDropdownList($rows, $valueCol,$textCol)
{
$newList = array();

foreach($rows as $row)
{
$value = $row[$valueCol];
$text = $row[$textCol];

$newList[$value] = $text;
//Syntax
//Newarayname[id col from Db]= text coloumn name from db
}
return $newList;

}



then do Like that Controller page

$students = $stud->selectStudentName();
$this->render('student', array('rows' => $rows));

then take rows value in student.php in view page area
0

#3 User is offline   developer! 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 110
  • Joined: 28-November 12

Posted 25 January 2013 - 07:48 AM

thanks for your reply karthik..

I did it now in other way.
0

#4 User is offline   karthik123 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 23
  • Joined: 23-November 12
  • Location:Tamilnadu,coimbatore,India

Posted 27 January 2013 - 11:26 PM

View Postdeveloper!, on 25 January 2013 - 07:48 AM, said:

thanks for your reply karthik..

I did it now in other way.




5n:)
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users