I am a newbie in php+Zend programming, so need your valuable advice. 1. I have a table in mysql (phpmyadmin), the attributes in the table are ~ user_id, expense_id, date month, year, expense. 2. I have .phtml file (index.phtml) in the View folder (Zend 2.2). It is accessed by indexAction() in the Controller page. Code:
return viewmodel ( return array=>( 'years'=>$this->getExpenseTable()->fetchAll($user_id); )),
[sorry if it's not in the proper format]. This function is meant to return all the values from the db, when I put it into a table with foreach. The code in index.phtml is below:
escapeHtml($expense->expense);?> .....and so on......
Now my problem is: a) I cannot use the variable 'years' in another table with another foreach loop in the same index.phtml file. it says, "this is a forward-only result-set." I tried implementing unset() and rewind(), both did not work. b) I want to take unique value of the attribute 'year' from the table (as table header you might think) and put the summation of expenses under each year.