0

I have created this script based off of a youtube tutorial:

<?php

if (($handle = fopen("guide.csv","r")) !== FALSE)
{
    $impairment = [];
    $provider = [];
    $description = [];

while (($data = fgetcsv($handle,1000,",")) !== FALSE)
{
    $impairment[] = $data[0];
    $provider[] = $data[1];
    $description[] = $data[2];
}
fclose($handle);
}
?>

and then I am attempting to echo the HTML in arrays and loop it for each row:

<?php
$arraySize = count($name);
$i = 0;

while($i < $arraySize)
{
    echo "<section class=\"section\">";
    echo "<p class=\"title\"><a href=\"#\"><i class=\"icon-down-open-big\"></i>" .$impairment[$i]."</a></p>";
    echo "<div class=\"content\"><ul class=\"side-nav\"><li><div><table class=\"statustab\"><tr>";
    echo "<td><h1>" .$provider[$i]. "</h1></td>";
    echo "<td><p class=\"statusp\"><span></span></p></td></tr><tr>";
    echo "<td><p>" .$description[$i]. "</p></td>";
    echo "</tr></table></div></li></ul></div></section>";
    $i++;

}
?>

My CSV file is simply this:

Addisons Disease,Phoenix Safe Harbor,Standard to Decline
ADHD/ADD,Phoenix Safe Harbor,Standard
ADLs (requires assistance),Phoenix Safe Harbor,Decline

But it seems something isn't right with this code and I can't get it to work properly. I've looked at several PHP manuals but for this specifically I cannot get the variables to work.

Any help is appreciated. This will be the finished product populated with a CSV file: http://247medplan.com/grid/

Leo Ashcraft
  • 35
  • 1
  • 9
  • Where does `$name` comes from? Also do you get any errors? (Add error reporting at the top of your file(s): ``) – Rizier123 Apr 14 '15 at 22:17
  • $name should be $impairment. I am getting this error already - Parse error: syntax error, unexpected '[' in /.../html/247med/grid/code.php on line 6 – Leo Ashcraft Apr 16 '15 at 15:33
  • What is the output of: `echo phpversion();` ? – Rizier123 Apr 16 '15 at 15:35
  • Thanks for the answer - if I upgrade my server to PHP 5.4+ will it break anything already running on 5.2? – Leo Ashcraft Apr 16 '15 at 15:50
  • No, as far as I know it shouldn't break anything. But if you upgrade to 5.5 or in the future to PHP 7 you have to upgrade the code and make sure you don't use deprecated functions and such stuff – Rizier123 Apr 16 '15 at 15:52

0 Answers0