php - List with duplicate entries -
i got minor problem. start, have following tables: 'groups', 'pages' , junction table 'subcriptions'
the idea behind group (with users) can subsribe page. user can add page subscription group in. (many-to-many). information: user can in multiple groups.
as part of ui want make list that. every group want associated pages. example: (group: ... pages: -.... , -.... | group: ... pages: -...., -.... etc.)
the sql query not issue:
select groups.name, pages.name, pages.id groups join subscriptions on groups.id = subscriptions.group_id join pages on subscriptions.page_id = pages.id groups.id in ('1', '2') // de values 1 & 2 zijn voorbeelden en stellen de groepen id's voor waarin de huidige gebruiker zit. the result will, example, this:
group name ---- page name ---- page id group1 -------- page1 --------- 1 group1 -------- page2 --------- 2 group2 -------- page1 --------- 1 my question is; how can (html) list single group-name , associated pages group? (like example mentioned earlier). need php solution. (i using zend framework, not find solution in zend trick want)
or have single query every group? avoid though..
i new in world of mysql , php every worth allot! thanks. :)
a basic implementation following:
- loop through mysql results
- build 2-dimensional array group 1st , associated pages 2nd dimension
- in html template, take array , use outer loop go through groups , inner loop pages per group
cheers :)
Comments
Post a Comment