close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues


Grouping results by category

Thread began 7/31/2012 12:29 pm by iainmacdonald331081 | Last modified 7/31/2012 12:51 pm by iainmacdonald331081 | 294 views | 2 replies |


Grouping results by category

Not one for any time to be spent on, but may be quite simple if you're better with PHP than I am.

I have a table with the structure:

ActivityID, Category, Activity

And have this section to return results:

<table width="100%"  border="0" cellpadding="0" cellspacing="0">
<?php do { ?>
<td><?php echo $row_ItineraryProfiles['Category']; ?></td>
<td><?php echo $row_ItineraryProfiles['Activity']; ?></td>
<?php } while ($row_ItineraryProfiles = mysql_fetch_assoc($ItineraryProfiles)); ?>

Which returns:

Category 1, Activity 1
Category 1, Activity 2
Category 1, Activity 3
Category 2, Activity 4
Category 2, Activity 5
Category 2, Activity 6

Is it simple (if you know how) to change that to return:

Category 1
Activity 1
Activity 2
Activity 3

Category 2
Activity 4
Activity 5
Activity 6


Sign in to reply to this post

Jason ByrnesWebAssist

a variable to hol the category value and an if statement should do the trick:

<table width="100%"  border="0" cellpadding="0" cellspacing="0">

  <?php $Category ""?>
  <?php do { ?>
  <?php if($Category !=  $row_ItineraryProfiles['Category']) { ?>
    <td><?php echo $row_ItineraryProfiles['Category']; ?></td>
    <td><?php echo $row_ItineraryProfiles['Activity']; ?></td>
  <?php } while ($row_ItineraryProfiles mysql_fetch_assoc($ItineraryProfiles)); ?>
Sign in to reply to this post


Thanks Jason - that's perfect.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question





Ease of use


security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...