You are here: Re: Need help with my code reading flat file into HTML table « PHP Programming Language « IT news, forums, messages
Re: Need help with my code reading flat file into HTML table

Posted by Geoff Berrow on 01/21/06 20:02

Message-ID: <Tv6dnRECt6mD80_eRVn-rQ@comcast.com> from JackM contained
the following:

>Can anyone show me the error of my ways? It's probably something dumb
>but I've worked on this for two days now trying all kinds of variations
>and can't get it to work. Thanks for any help.
<?php
$file = "file.txt";
$cols=4;
$pos=0;
$result = file($file);
$lines = count($result);
$spaces=($lines%$cols>0)? 1 : 0;
$rows=floor($lines/$cols)+$spaces;
echo "<table border='2'>\n";

for($i=0;$i<$rows;$i++){
echo "<tr>\n";
for($j=0;$j<$cols;$j++){
if(isset($result[$pos])){
echo "\t<td>".trim($result[$pos])."</td>\n";
}
else{
echo "\t<td>&nbsp;</td>\n";
}
$pos++;
}
echo "</tr>\n";
}
echo "</table>";
?>

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/

 

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

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