Jump to content

categorizing the results of an sql statement


darga333

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.