TomT Posted September 23, 2009 Share Posted September 23, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/175196-solved-formatting-tables/ Share on other sites More sharing options...
sasa Posted September 23, 2009 Share Posted September 23, 2009 http://www.phpfreaks.com/forums/index.php/topic,95426.0.html Quote Link to comment https://forums.phpfreaks.com/topic/175196-solved-formatting-tables/#findComment-923416 Share on other sites More sharing options...
TomT Posted September 24, 2009 Author Share Posted September 24, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/175196-solved-formatting-tables/#findComment-923965 Share on other sites More sharing options...
play_ Posted September 24, 2009 Share Posted September 24, 2009 What does this do? If the remainder of $cols / 3 is 0, insert </tr><tr> So basically, it creates 3 <td>s before creating a new <tr> Quote Link to comment https://forums.phpfreaks.com/topic/175196-solved-formatting-tables/#findComment-923967 Share on other sites More sharing options...
TomT Posted September 25, 2009 Author Share Posted September 25, 2009 Thanks Quote Link to comment https://forums.phpfreaks.com/topic/175196-solved-formatting-tables/#findComment-924802 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.