views:

37

answers:

2

iam executing a stored procedure in php and iam returning an array ["record"]=> array(1175) { [0]=> array(20) { ["Col1"]=> string(1) "Mode" ["col2"]=> string(16) "type" } }

how do i get the col1 and col2 values from the array and assign it to the view .what should i say $view-.results = $result_val['record']; $view->col1 = ???? $view->col2 = ????

+1  A: 

From the controller you assign data to the view using:

$this->view->myData = "something";

Then in the view phtml file:

echo $this->myData;

So in the controller its $this->view and in the view its $this.

In your case assuming your array is called $records:

$this->view->records = $records;

then in your view:

foreach($records as $record){
   echo 'Col1 = ' . $record['Col1']. "<BR />";
   echo 'Col2 = ' . $record['Col2']. "<BR />";
}

Hope this helps.

Iznogood
@lznogood: How do i assign value of "Something " from an array that is my problem
Someone
@Someone edited my answer.
Iznogood
@Someone if that still doesnt help I suggest you post more code and make use of the code formater. Its the 001001 button when you post/edit your questions.
Iznogood
A: 

In the Controller:

$this->view->record=$record[0]

In the View:

echo $this->record["col1"]
echo $this->record["col2"]
evildead