darga333 Posted May 9, 2006 Share Posted May 9, 2006 I am having a problem displaying the result of my sql statement in groups. It needs to spit out the first category, then the first business name in that category, then all of the Headlines for that business... then it needs to just loop and do it again for each business in that same category.. and then it needs to move to the next category and repeat the process.I am only using 1 SQL statement that is relatively simple [code]$sql_1 = "SELECT t1.sHeadlines,t2.sName,t3.sBusinessname FROM ucfdiscount t1,ucfdiscountcategory t2,ucfmembers t3 WHERE t3.user_id = t1.iMemberId AND t1.iDisCategoryId = t2.idiscategoryid ORDER BY t2.sName, t3.sBusinessname, t1.sHeadlines ASC";$result_1 = mysql_query($sql_1);$row_1 = mysql_fetch_array($result_1);$num33 = mysql_num_rows($result_1);if ($num33 > 0) { $message = $row_1['sName']; $message.= $row_1['sBusinessname']; $message.= $row_1['sHeadlines']; }[/code]I know I am missing the if statements inside the bracket that will allow me to do this. Will someone please help me figure this out.The logic is: For each Category display categoryFor each Business Name display business nameFor each Headline Display headline Do i just need 3 different for each statements? Thank you so much for helping me figure this out! Quote Link to comment Share on other sites More sharing options...
Barand Posted May 9, 2006 Share Posted May 9, 2006 I gave you a solution to this one in your previous post of this question.[a href=\"http://www.phpfreaks.com/forums/index.php?s=&showtopic=92932&view=findpost&p=371976\" target=\"_blank\"]http://www.phpfreaks.com/forums/index.php?...ndpost&p=371976[/a]Don't double post, you've already had one warning, and if you choose to ignore the solutions offered why bother to post at all? Quote Link to comment Share on other sites More sharing options...
darga333 Posted May 9, 2006 Author Share Posted May 9, 2006 I apologize for that but I am looking for a solution without Inner Joins and List variables. But thanks for your earlier response, it was much appreciated. Just a bit too confusing for me 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.