I have a two tables, Post and categories, Post have category_id
I can get all post_name | category_id
with $post[Category][name], I can get
Post | Category
Hello | php
World | php
Hi | php
Earth | php
Hello1 | asp
World1 | asp
Hi1 | asp
Earth1 | asp
How to get:
php
Hello
World
Hi
Earth
asp
Hello1
World1
Hi1
Earth1
Its group by but Logic has gone and dont know how to get them
edit: I think there should be first loop that gets Categories than second inside first that gets posts where post.cat_id = cat.id But in cake way I dont know how can I do this.
You can do this with one query in your
Categorycontroller and a nested loop in the view:in the
Categorycontroller:and in the view: