Jump to content

why is $atBats undefined?


Hillary

Recommended Posts

Also Try using Barands Solution to retrieve the information from the CSV file ;D

 

 

<?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);
?>

after looking at the fullcode i added is_array to make sure if it is an array or not :P

 

 

<?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>";
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.