Firstly I must thank Danny (Troon, Uk) for getting me started with implementing the page I wated. Its working at this page .... Members list at DLF.org.au
Now I need to modify the orginal script, find it here
I have tried to modify the script, as seen below, but all i get is a single column, but no link and no formating, plus the two characters "> keep appearing (as if they are being paresed improperly).
Please help ..... modifed script below ....
function csv2table($filename,$bgcolor=Array('#333333','#000000'),
$seperator=",") //- Altered from orginial script - column="1" was droped as a variable
{
$data=file($filename);
// Split each entry into a name and site
foreach($data as $row)
{
$row=explode($seperator,trim($row));
$names[$row[0]]=$row[1];
}
$newrow=$row=0; // Altered from orginial script: $column became $newrow and $count was dropped here aswell
// Print them
foreach($names as $name=>$site)
{
if (++$newrow%$newrow==1) // Starting a new row - Altered from orginial script
{
// Get next bgcolor, automatically loop around array
$row=++$row%count($bgcolor);
$tableArray[$row][]=$bgcolor[$row]; // $tableArray[$row] was tableArray[$count]
}
$tableArray[$row][]="<a href=\"$site\">$name</a>";
if ($newrow%$newrow==0) // Ending row - Altered from orginial script
$row++;
}
// Make sure the last row has correct number of columns;
count($names)%$newrow=1 ? $pad=$newrow-count($names)%$newrow : $pad=0; //- Altered from orginial script
for ($x=0;$x<$pad;$x++)
$tableArray[$row][]=" ";
return $tableArray;
}
$tableArray=csv2table('names.txt');
echo '<table width=\"620">';
foreach ($tableArray as $row)
{
echo "\n\t<tr style=\"background:".array_shift($row)."\">\n"; // the last pair of characters show up in the outout. ">
foreach ($row as $cell)
echo "\t\t<td>$cell</td>\n";
echo "\t</tr>\n";
}
echo "</table>";
This is fairly simple stuff but I need to get it right and pretty soon as the deadline for this section of my project is due very soon. Please help. Email me at Charlie
Oh and here is a sample text file to practice on ....