Outputting DB results in Column/Rows not just rows

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
EverToDesign
Forum Newbie
Posts: 10
Joined: Sat Oct 11, 2003 9:38 am

Outputting DB results in Column/Rows not just rows

Post by EverToDesign »

Hey there, got a question.

Usually when I output results its with a echo in a while loop that adds a new row constantly to the table.

However now I need it to output it so that theres records going across 3 columns and repeating down.

So instead of an HTML Table that outputs rows like

Record1
Record2
Record3
Record4
Record5
Record6

it'd be output as

Record1 Record2 Record3
Record4 Record5 Record6
Record7 Record8 Record9

in a table.

Anyone able to tell me how i'd go about on this?
User avatar
Johnm
Forum Contributor
Posts: 344
Joined: Mon May 13, 2002 12:05 pm
Location: Michigan, USA
Contact:

Post by Johnm »

You can put it in a loop and use modulus on the loop counter to determin when to echo out a </tr><tr> to create a new row.


John M
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post by Gen-ik »

Think about how the <table> needs to be built and then think about what you will need to do in your PHP loop.

This is a really easy problem to solve if you just sit down for 2 minutes and think about it.
Post Reply