darkfreaks Posted April 20, 2008 Share Posted April 20, 2008 Also Try using Barands Solution to retrieve the information from the CSV file <?php $f = fopen('hillary.csv', 'r'); echo '<table border="1">'; while ($row = fgetcsv($f,80)) { echo '<tr><td>' . join ('</td><td>', $row) . '</td></tr>'; } echo '</table>'; fclose ($f); ?> Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted April 20, 2008 Share Posted April 20, 2008 after looking at the fullcode i added is_array to make sure if it is an array or not <?php print"<center>"; print "<h1>Philadelphia Phillies 2008 Season Stats.</h1>"; echo "<table width=500 cellspacing=10>\n"; $data = array(); $data .= file("phillsstat.csv"); $record=array(); $i=0; if(is_array($record)||is_array($data)){ foreach($data as $line) { echo " <tr>\n"; $field= explode(",",$line); foreach($field as $value) { echo " <td>$value</td>\n"; } echo " </tr>\n"; }} echo "</table>"; print"</center>"; print" -------------------------------------------------------------------------------- </hr>"; print "<center>"; print "<h3>Enter New Stats and press Update</h3>"; print "</center>"; //print_r($_GET); //$avg=$past."=".$state; $atBats= array(); $hits= array(); $avg= array(); if(isset($atBats)) { $atBats[0]=0; $atBats[1]=0; $atBats[2]=0; $atBats[3]=0; $atBats[4]=0; } if(isset($hits)) { $hits[0]=0; $hits[1]=0; $hits[2]=0; $hits[3]=0; $hits[4]=0; } $avg=$atBats[0]+$hits[0]; $avg=$atBats[1]+$hits[1]; $avg=$atBats[2]+$hits[2]; $avg=$atBats[3]+$hits[3]; $avg=$atBats[4]+$hits[4]; //print "<p> Past:$past.State$state</p>\n"; print "<center>"; print"<form>\n"; print"<table><tr>"; print"<td valign=left>Rollins</td>"; print"<td valign=center> <input type=\"text\" \"hidden\" name=\"game[0]\" value=\"\"> <input type=\"text\" \"hidden\" name=\"$atBats[0]\" value=\"\"> <input type=\"text\" \"hidden\" name=\"$hits[0]\" value=\"\"> \n"; print"</td></tr>"; print"<tr><td valign=left>"; print" Howard</td>"; print"<td valign=center> <input type=\"text\" \"hidden\" name=\"game[1]\"> <input type=\"text\" \"hidden\" name=\"$atBats[1]\" value\"\"> <input type=\"text\" \"hidden\" name=\"$hits[1]\"> \n"; print"</td></tr>"; print"<tr><td valign=left>"; print"Burrell</td>" print"<td valign=centet> <input type=\"text\" \"hidden\" name=\"game[2]\"> <input type=\"text\" \"hidden\" name=\"$atBats[2]\" value\"\"> <input type=\"text\" \"hidden\" name=\"$hits[2]\"> \n"; print"</td></tr>"; print"<tr><td valign=left>Victorino</td>"; print"<td valign=center> <input type=\"text\" \"hidden\" name=\"game[3]\"> <input type=\"text\" \"hidden\" name=\"$atBats[3]\" value\"\"> <input type=\"text\" \"hidden\" name=\"$hits[3]\"> \n"; print"</td></tr>"; print"<tr><td valign=left>Utley</td>"; print"<td valign=center> <input type=\"text\" \"hidden\" name=\"game[4]\"> <input type=\"text\" \"hidden\" name=\"$atBats[4]\" value\"\"> <input type=\"text\" \"hidden\" name=\"$hits[4]\"> \n"; print"</td></tr></table>"; print"<input type=\"submit\" value=\"Update\">\n"; print"<input type=\"submit\" value=\"Undo Stat Changes\">\n"; print "</form>\n"; print "</center>"; ?> Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted April 20, 2008 Share Posted April 20, 2008 also you might want to check if your submitted variables are isset or empty Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.