Hey thanks for the help it seemed to be the <br/> tags, thanks for the rewrite I compared to mine and made adjustments accordingly. the final code takes your style which I am lacking in and and also your for each block. I appreciate it because im really trying to become a great programmer, not just capable of doing it. If you have any suggestions on how I could improve please let me know, and again thanks for the help.
final code:
<?php
// this script reads data from a text file
// open file and read data
$fp=fopen("nflstats.csv", "rw");
if (!$fp){
echo "Could not open the file!";
exit();
}
displayData($fp);
function displayData($fp){
$line1 = fgets($fp, 256);
$ratings = array();
while(!feof($fp)){
//read one line at a time
$line= fgets($fp, 256 );
$total= 0;
//Split the data using explode() function
if($line !=""){
$info=explode(",", $line);
$player_name = $info[0];
$c_value = ($info[2]*100/$info[3] - 30)/20;
$y_value = ($info[4]/$info[3] - 3)/4;
$t_value = $info[5]*20/$info[3];
$i_value = 2.375 - $info[6]*35/$info[3];
$pass_rating =round(($c_value + $y_value + $t_value + $i_value)*100/6, 2);
$ratings[$player_name]= $pass_rating;
}
}
arsort($ratings);
echo "<table border=1>";
echo "<tr><td colspan=\"3\" ><h2>"."NFL Player Pass Ratings"."</h2></td></tr>";
echo "<tr><th>Name</th><th>Pass Rating</th></tr>\n";
foreach ($ratings as $player_name=>$pass_rating){
echo "<tr><td>{$player_name}</td><td>{$pass_rating}</td></tr>\n";
}
echo"</table>\n";
echo"<table border=1>";
echo "<tr><th colspan=\"22\" ><h2>"."NFL Player Pass Ratings: Great, Good, Mediocre"."</h2></td></tr>";
echo "<tr><th>Name</th><th>Pass Rating</th></tr>\n";
foreach ($ratings as $player_name=>$pass_rating){
if($pass_rating > 95) {
$rating_label = "Great";
} elseif($pass_rating >90){
$rating_label = "Good";
} elseif($pass_rating >85){
$rating_label = "Mediocre";
} else{
$rating_label = "Terrible";
}
echo "<tr>\n";
echo "<td>{$player_name}</td><td>{$pass_rating}<b> -- {$rating_label}</b></td>\n";
echo "</tr>\n";
}
echo"</table>\n";
}
?>