poe Posted October 27, 2007 Share Posted October 27, 2007 i have a db table that has linkid cat id and page number linkid catid page 1 1 1 2 1 1 3 1 1 4 1 2 5 1 2 6 1 2 7 1 3 8 2 1 9 2 1 10 2 1 11 3 1 12 3 1 13 3 2 14 3 2 15 3 3 16 3 3 17 3 4 18 3 4 etc..... i need to create this into an array that is in a structure like: array [catid] => grouped by catid and just the unique pages so cat1 has pages 1,2,3 cat2 has pages 1 cat3 has pages 1,2,3,4 Quote Link to comment Share on other sites More sharing options...
Barand Posted October 27, 2007 Share Posted October 27, 2007 $catpages = array(); $result = mysql_query("SELECT DISTINCT catid, page FROM tablename"); while ($r = mysql_fetch_assoc($result)) { $catpages[ $r['catid'] ][] = $r['page']; } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.