I have this code below to read the contents of a CSV file and display on a webpage. It should also alternate the background color of the row i.e. white, blue, white blue etc. But i keep getting the following error:
Parse error: syntax error, unexpected T_ECHO, expecting ',' or ';' in C:\XAMPP\xampp\htdocs\products.php on line 51
Can you please check the code and test it and let me know why i am getting this error? Thanks. Speedy response is as usual very much appreciated.
$dir_name = "C:/htdocs/catalogue.txt";
$fh = fopen($dir_name, "r");
$c = 0;
while(($data = fgetcsv($fh, 1000, ",")) !== FALSE)
echo "<tr bgcolor=\""
if ($c % 2 == 1) echo "#0000FF"; else echo "#FFFFFF";
$num = count($data); // count the # of lines that exist
$row++; //increment the row variable to the next line
//output current line to the screen.
for ($i=0; $i < $num; $i++)