Page 1 of 1

Displaying data in a table

Posted: Fri Nov 29, 2002 9:31 am
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?

Posted: Fri Nov 29, 2002 10:54 am
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!