|
Posted by iktorn on 04/26/07 07:45
_Skare_Krow_ napisał(a):
> I have a database with three columns. One is an atomic number, one is a
> pic url, and the other is a description. What I'm having trouble doing
> is putting the url in one table row and the description in another table
> row right below it like this...
> <tr> <td> some pic url</td> <td> other pic url</td></tr>
> <tr><td> some descripts </td> <td> other descript </td></tr>
>
> whilest limiting the rows to about 10 cells each,,....
>
> any ideas?
>
> Aaron
The easiest way is to use CSS - div + float property.
<?php
$arr =array(
array("file1","desc1"),
array("file2","desc2"),
array("file3","desc3"),
array("file4","desc4"),
array("file5","desc5"),
array("file6","desc6"),
array("file7","desc7"),
);
define('TABLE_COLS',4);
print "<table>".PHP_EOL;
$i=1;
while(list($key,$row) = each($arr)) {
$tmp[$i]=$row;
if($i++==TABLE_COLS) {
print "<tr>";
for($j=1;$j<=TABLE_COLS;$j++) {
print "<td>".$tmp[$j][0]."</td>";
}
print "</tr>".PHP_EOL;
print "<tr>";
for($j=1;$j<=TABLE_COLS;$j++) {
print "<td>".$tmp[$j][1]."</td>";
}
print "</tr>".PHP_EOL;
$i=1;
}
}
if($i>1) {
print "<tr>";
for($j=1;$j<=TABLE_COLS;$j++) {
print "<td>".(($j<$i)?$tmp[$j][0]:"")."</td>";
}
print "</tr>".PHP_EOL;
print "<tr>";
for($j=1;$j<=TABLE_COLS;$j++) {
print "<td>".(($j<$i)?$tmp[$j][1]:"")."</td>";
}
print "</tr>".PHP_EOL;
}
print "</table>";
--
Wiktor Walc
http://phpfreelancer.net
Navigation:
[Reply to this message]
|