Jump to content

Archived

This topic is now archived and is closed to further replies.

darga333

categorizing the results of an sql statement

Recommended Posts

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 category
For each Business Name display business name
For each Headline Display headline

Do i just need 3 different for each statements? Thank you so much for helping me figure this out!

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.