Build dynamic table with 4 columns at most

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • samvb
    New Member
    • Oct 2006
    • 228

    #1

    Build dynamic table with 4 columns at most

    Hi,

    From a database, I need to build a dynamic table that looks like this:

    ITEM1 ITEM2 ITEM3 ITEM4
    ITEM5 ITEM6

    It is dynamic. Sometimes only there could be 1 item or more than 4 items. I have tried 2 loops but it didn't work at all. My main problem is closing and ending the rows. And if the next row is less than 3 item, it is another problem.

    Sorry, I don't speak English well.
  • JKing
    Recognized Expert Top Contributor
    • Jun 2007
    • 1206

    #2
    Use two tables instead.

    For example let's say I get lots of orders for items. Each order could potentially have several items. Therefore we should make a table for orders and a table for items and relate them. This way each item would have an order ID. So it doesn't matter how many items you need to store.

    Comment

    • samvb
      New Member
      • Oct 2006
      • 228

      #3
      Hi,

      my problem is not the database design. JUST THE OUTPUT. I mean, how can i display 4 items per row, then open another <tr> for next 3,4 items...

      Comment

      Working...