Displaying data in a table

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
Deddog
Forum Commoner
Posts: 55
Joined: Thu Sep 26, 2002 6:05 am
Location: Brighton

Displaying data in a table

Post by Deddog »

Help.

I have written some code that dynamically displays employees contact details in a table.

The table is 6 columns wide. My problem is that I want to display the details in alphabetical order with the data being directed downwards. When the first column is full I then want it to start in the next column and work downwards again.

I have only been able to build the table with the data scrolling horizontally.

Any ideas?
f1nutter
Forum Contributor
Posts: 125
Joined: Wed Jun 05, 2002 12:08 pm
Location: London

Post by f1nutter »

Try nesting tables within a table

Code: Select all

<table>
 <tr>
  <td>
   <table>
    <tr>
     <td>emp1</td>
     <td>emp2</td>
    </tr>
   </table>
  </td>
  <td>
   <table>
    <tr>
     <td>emp3</td>
     <td>emp4</td>
    </tr>
   </table>
  </td>
 </tr>
</table>
You can see the pattern, and you just need to code the repetative parts. You say you need 6 columns, so divide the number of records by 6, round up, and this gives you the number of rows per column (rows per inner table) for correct displaying. Don't forget to handle the blank rows in the final column!
Post Reply