Hello John, PHP I used your script almost everything is worked. Thanks. Here is the script if someone will need it :)
<? $count = 1; $Num_Across = 4; $Width = floor(100 / $Num_Across); while($row = MySQL_fetch_array($result)) { //create first cell $tttt = $count / $Num_Across; echo "<td width='".$Width."'>".$row['name']."</td>\n"; //keep a count so you know when to start a new row if(round($tttt) == $tttt) { echo "</tr><tr>\n"; } $count++; }; //this will finish the table, i.e. if you only have one //name on last row, this will fill in the remaining table //cells $left = $Num_Across - (--$count % $Num_Across); for($x=0;$x<$left;$x++) { echo "<td> </td>\n"; }; echo "</tr>"; echo "</table>"; ?> Friday, June 21, 2002, 3:42:24 PM, you wrote: >> I've got the following situation: I have a list of items i want JH> placed >> in side-by-side columns in a table like this: >> >> name name name name >> name name name name >> name name name name >> name name name name >> >> and so on. How can I do it? Name is a string in the database. JH> You can try something like this: JH> <? JH> $Count = 1; JH> $Num_Across = 4; JH> $Width = floor(100 / $Num_Across); JH> //start table and first row JH> echo "<table width='100%'>\n"; JH> echo "<tr>\n"; JH> while($row = MySQL_fetch_array($result)) JH> { JH> //create first cell JH> echo "<td width='$width'>".$row['name']."</td>\n"; JH> //keep a count so you know when to start a new row JH> if($count % $Num_Across == 0) JH> { $retval .= "</tr><tr>\n"; } JH> $count++; JH> } JH> //this will finish the table, i.e. if you only have one JH> //name on last row, this will fill in the remaining table JH> //cells JH> $left = $Num_Across - (--$count % $Num_Across); JH> for($x=0;$x<$left;$x++) JH> { echo "<td> </td>\n"; } JH> That last part isn't tested. I used a different method, but hopefully JH> this gives you an idea. JH> ---John Holmes... -- Best regards, Latex mailto:[EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php