Jump to content

[SOLVED] Formatting Tables..


TomT

Recommended Posts

Hi

 

I'm retrieving data from an LDAP database and try to format the results into a neat table !! (getting the data is working fine, it just the formatting)

 

The LDAP is:

	   $info = ldap_get_entries($ds, $sr);
     		for ($p=0; $p<$info["count"]; $p++) {		
			echo $info[$p]['UserID'][0]. "<br>";
		}  

 

Instead of just writing the UserID I'd like to insert it into this table.

There are only 16 UserID's.

 

To make things interesting I would like entries 1 - 8 on the top row and entries 9 - 16 on the bottom row.

 

 

The table should look like this:

 

<table border='0' width='100%'>
  <tr>
    <td width='46%'>
      <table border='1' width='100%'>
        <tr>
          <td width='12%'>UserID_1</td>
          <td width='12%'>UserID_2</td>
          <td width='12%'>UserID_3</td>
          <td width='12%'>UserID_4</td>
          <td width='13%'>UserID_5</td>
          <td width='13%'>UserID_6</td>
          <td width='13%'>UserID_7</td>
          <td width='13%'>UserID_8</td>
        </tr>
        <tr>
          <td width='12%'>UserID_9</td>
          <td width='12%'>UserID_10</td>
          <td width='12%'>UserID_11</td>
          <td width='12%'>UserID_12</td>
          <td width='13%'>UserID_13</td>
          <td width='13%'>UserID_14</td>
          <td width='13%'>UserID_15</td>
          <td width='13%'>UserID_16</td>
        </tr>
      </table>
    </td>
    <td width='54%'></td>
  </tr>
</table>

 

Can anyone help with this ??

 

Thanks :)

Link to comment
https://forums.phpfreaks.com/topic/175196-solved-formatting-tables/
Share on other sites

Thanks.

Read the link and used a slightly changed version of this to sort it !!

 

 

<?php
   $cols = 0;
   echo "<table><tr>";
   while ($cols < 20) {
      echo ($cols % 3 == 0)? "</tr><tr>" : "";
      echo "<td>$cols</td>";
      $cols++;
   }
   echo "</tr></table>";
?> 

 

One question..

What does this bit do ?

 

echo ($cols % 3 == 0)?

 

Thanks

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.