As a complete beginner, I've written a cgi-script which is writing data (delimited by a ; )into a textfile.
So far so good........but now I have tryed to author a php to display the data into a table:
<?
function my_fgetcsv($filename,$sep) {
$arr=file($filename);
$erg=array("");
foreach ($arr as $elem); {
$str=$elem;
$buf=explode ($sep,$str);
$erg=array_merge($erg,$buf);
}
array_shift($erg);
return $erg;
}
function table_out($rows,$cols,$arr,$width,$border,$cp,$cs,$color) {
reset ($arr);
$cellwd=100/$cols."%";
echo "<table width='$width' border='$border' cellpadding='$cp' cellspacing='$cs'>";
for ($c=0;$c<$cols;$c++) {
$elem=pos($arr);
echo "<th width='$cellwd' bgcolor='$color'>$elem</th>";
next($arr);
}
for ($r=1;$r<$rows;$r++) {
echo "<tr>";
for ($c=0;$c<$cols;$c++) {
$elem=pos($arr);
echo "<td bgcolor='$color'>$elem</td>";
next($arr);
}
echo "</tr>";
}
echo "</table>";
}
$arr=my_fgetcsv("tabelle.txt",";");
table_out(3,6,$arr,"90%",0,2,2,"#E8E8E8");
?>
Unfortunately this doesn't work cause my webhost only runs PHP3 :-((
Can anyone tell me how to do this in php3 incluing the
function table_out($rows,$cols,$arr,$width,$border,$cp,$cs,$color)
with all it's parameters??
Thanks for your help :-)
Regards from Switzerland,
Brigitte