Hi, you can accomplish this by adding a GROUP BY clause to your SQL query, then you would use an ORDER clause to have the years ascending or descending.

In your case you would group by year.

Look at Zend_Db_Select in the manual, here you will find examples.

Thanks

On 2 Jan 2010, at 08:16, Enkhbilguun Erdenetsogt <[email protected]> wrote:

Happy New Year,

I would like to print articles list ordered/grouped by year column of my db table, but I can't find how I should loop to print something like the following:

2007 (column year)
Article 1 (column cat_id)
Sub Article 1 (column name with description)
Sub Article 2
Sub Article 3
Article 2
Article 3
Article 4

To print the above list with the below table data, I need to make all the same year value to one and every articles (column cat_id) should be included in it, but because of my poor knowledge of php and OOP, I couldn't find simple way to loop them.

My table structure looks:

id | type | cat_id | year | name | description ......



Thank you for your help my friends.


---
Enkhbilguun Erdenetsogt
<enkhbilguun.vcf>

Reply via email to