You are here: Re: html table trouble « PHP Programming Language « IT news, forums, messages
Re: html table trouble

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация