cs netbean questions

profileyyk112233
lab5.php

<?php // **** Open Weather Data ********************************** $debug = false; if(isset($_GET["debug"])){ $debug = true; } $myFolder = 'data/'; $myFileName = 'lab5'; $fileExt = '.csv'; $filename = $myFolder . $myFileName . $fileExt; if ($debug) print '<p>filename is ' . $filename; $file=fopen($filename, "r"); if($debug){ if($file){ print '<p>File Opened Succesful.</p>'; }else{ print '<p>File Open Failed.</p>'; } } // **** End Open Weather Data ********************************** // **** Read Weather Data ********************************** if($file){ if($debug) print '<p>Begin reading data into an array.</p>'; // read the header row, copy the line for each header row // you have. $headers[] = fgetcsv($file); if($debug) { print '<p>Finished reading headers.</p>'; print '<p>My header array</p><pre>'; print_r($headers); print '</pre>'; } // read all the data while(!feof($file)){ $weahtherDetails[] = fgetcsv($file); } if($debug) { print '<p>Finished reading data. File closed.</p>'; print '<p>My data array<p><pre> '; print_r($weahtherDetails); print '</pre></p>'; } } // ends if file was opened ?> // **** End Read Weather Data ********************************** ?> <!DOCTYPE HTML> <html lang="en"> <head> <title>BTV Burlington Weather Data</title> <meta charset="utf-8"> <meta name="author" content="Haoyue Qi"> <meta name="description" content="the lab to take about how to use the CSV" > <link rel="stylesheet" href="css/custom.css" type="text/css" media="screen"> </head> <body id="lab5"> <header> <h1>BTV Burlington Weather Data</h1> </header> <article id="content"> <h2>Weather change</h2> <table> <?php foreach ($headers as $header) { print'<tr>'; print'<th>' . $hearder[0] . '</th>'; print'<th>' . $hearder[1] . '</th>'; print'<th>' . $hearder[2] . '</th>'; print'<th>' . $hearder[3] . '</th>'; print'<th>' . $hearder[4] . '</th>'; print'<th>' . $hearder[5] . '</th>'; print'<th>' . $hearder[6] . '</th>'; print'<th>' . $hearder[7] . '</th>'; print'<th>' . $hearder[8] . '</th>'; print'<th>' . $hearder[9] . '</th>'; print '</tr>' . PHP_EOL; } foreach ($weahtherDetails as $weahtherDetail) { print'<tr>'; print'<td>' . $weahtherDetail[0] . '</td>'; print'<td>' . $weahtherDetail[1] . '</td>'; print'<td>' . $weahtherDetail[2] . '</td>'; print'<td>' . $weahtherDetail[3] . '</td>'; print'<td>' . $weahtherDetail[4] . '</td>'; print'<td>' . $weahtherDetail[5] . '</td>'; print'<td>' . $weahtherDetail[6] . '</td>'; print'<td>' . $weahtherDetail[7] . '</td>'; print'<td>' . $weahtherDetail[8] . '</td>'; print'<td>' . $weahtherDetail[9] . '</td>'; print '</tr>'. PHP_EOL; } print '<tr><td colspan="10">' . count($weatherDetails) . ' Total Daily Observations</td></tr>'; ?> </table> </article><!-- end content --> </body> </html>