Results 1 to 3 of 3

Thread: [RESOLVED] printing/sorting html table from 3 db tables

  1. #1
    Join Date
    Mar 2009

    resolved [RESOLVED] printing/sorting html table from 3 db tables

    I want to print some of my database's contents out into a table. If you click on a column heading, it will print out a sorted table.

    I have data from 3 different tables that need to be put into this one html table. So I figure I print out everything from the 1st table, then add the 2nd table, and then the 3rd table's data goes in as the last column of the html table. This works fine.

    The problem comes with sorting the table. The only thing these 3 db tables have in common is an ID. So when I print the html table originally, everything's fine because everything is ordered by ID and, therefore, matches up correctly.
    But if I want to sort by product, it will sort the one table fine, but the others don't have that attribute. So when I print the data from those tables out, they aren't going to be matched up with the correct ID any more.

    Is there any way to make the sorting still work correctly?
    The only thing I can think of is to put all the data that needs to be printed out into 1 table, but that doesn't make for the best database design.
    Should I have posted this in a specific language forum instead?

  2. #2
    Join Date
    Mar 2009
    If each table shares an ID, then join them together in one query and the order by will sort it all.

  3. #3
    Join Date
    Mar 2009
    of course! Only write ONE query. It seems so obvious now. thank you
    I got it working just fine

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center