dannybrazil Posted August 12, 2011 Share Posted August 12, 2011 Hello, I have a DB with lots of rows...some sort of comments for each article. Lets say the articles have an ID (AR001,AR002...AR100). Each author write articles freely, so I cant know how many each has. Now each article gets various numbers of comments, which I cannot know before hand, and the ROW ID is mixed. I want to print the authors, their articles (ordered) and comments for each. The thing is...how do I capture ONLY ONCE the article code? I mean id AR001 has 100 comments, how do I get JUST the article code ONCE and then another while loop to get the comments. Ex. Danny Sheps Article 1 comment 1 comment n Article 2 comment 1 comment n Article n comment 1 comment n hope you got it....Thanks Link to comment https://forums.phpfreaks.com/topic/244622-php-ordering-scattered-rows/ Share on other sites More sharing options...
djlee Posted August 12, 2011 Share Posted August 12, 2011 $r = mysql_query('select articles'); while($a = mysql_fetch_assoc($r) { echo "article".$a['article_name']; $r2 = mysql_query('select commects where article = '. $a['articleID']); while($a2 = mysql_fetch_assoc($r2) { //echo comment here } } Link to comment https://forums.phpfreaks.com/topic/244622-php-ordering-scattered-rows/#findComment-1256421 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.