plz help
<?php
$file= "survey.txt";
if(!file_exists($file)){echo"file does not exist.\n";}
else{
$lines=file($file);
echo "There are " . count($lines) . "survey entries.\n<br>";
echo "They are...<br><br>\n";
for($i=0; $i<count($lines); $i++){
echo "$lines[$i] <br>\n";
}
}
//grade
$count9=0;
$count10=0;
$count11=0;
$count12=0;
//gender
$countM=0;
$countF=0;
//left or right handed
$countLeft=0;
$countRight=0;
//gender and left or right handed
$countMaleLeft=0;
$countMaleRight=0;
$countFemaleLeft=0;
$countFemaleRight=0;
$count = count($lines);
for($lineNumber=0;$lineNumber<count($lines);$lineNumber++){
$lineArray=split(",",$lines[$lineNumber]);
//grade level
if($lineArray[2]==9) { $count9++; }
if($lineArray[2]==10){ $count10+1; }
if($lineArray[2]==11){ $count11+1; }
if($lineArray[2]==12){ $count12+1; }
//gender
if($lineArray[3]=="male"){ $countM++; }
else if($lineArray[3]=="female"){ $countF++; }
//left or right handed
if($lineArray[4]=="left"){ $countLeft++; }
else if($lineArray[4]=="right"){ $countRight++; }
// gender with left or right handed
if($lineArray[3]=='male' && $lineArray[4]=="left"){ $countMLeft++; }
else if($lineArray[3]=='male' && $lineArray[4]=="right"){ $countMRight++; }
if($lineArray[3]=='female' && $lineArray[4]=="left"){ $countFLeft++; }
else if($lineArray[3]=='female' && $lineArray[4]=="right"){ $countFRight++; }
}
//bar graphs
echo <<< GRAPH
<center>
<img src=analyze.gif>
<br>
Data Bar Graph
<br><br>
Grade Level <?php echo $count ?> Entries
<table border=1 cellpadding=0 cellspacing=0 bordercolor=#000000>
<tr>
<th valign=bottom><?php echo $count9 ?></th>
<th valign=bottom><?php echo $count10 ?></th>
<th valign=bottom><?php echo $count11 ?></th>
<th valign=bottom><?php echo $count12 ?></th>
</tr>
<tr>
<th valign=bottom><?php printf("%5.1f", 100$count9/$count) ?>%</th>
<th valign=bottom><?php printf("%5.1f", 100$count10/$count) ?>%</th>
<th valign=bottom><?php printf("%5.1f", 100$count11/$count) ?>%</th>
<th valign=bottom><?php printf("%5.1f", 100$count12/$count) ?>%</th>
</tr>
<tr>
<th valign=bottom><img src=green.gif width=10 height="<?php echo $count9 ?>"></th>
<th valign=bottom><img src=green.gif width=10 height="<?php echo $count10 ?>"></th>
<th valign=bottom><img src=green.gif width=10 height="<?php echo $count11 ?>"></th>
<th valign=bottom><img src=green.gif width=10 height="<?php echo $count12 ?>"></th>
</tr>
<tr>
<th>9th</th>
<th>10th</th>
<th>11th</th>
<th>12th</th>
</tr>
</table>
<br>
Gender<?php echo $count ?> Entries
<table border=1 cellpadding=0 cellspacing=0 bordercolor=#000000>
<tr>
<th valign=bottom><?php echo $countM ?></th>
<th valign=bottom><?php echo $countF ?></th>
</tr>
<tr>
<th valign=bottom><?php printf("%5.1f", 100$countM/$count) ?>%</th>
<th valign=bottom><?php printf("%5.1f", 100$countF/$count) ?>%</th>
</tr>
<tr>
<th valign=bottom><img src=blue.gif width=10 height="<?php echo $countM ?>"></th>
<th valign=bottom><img src=blue.gif width=10 height="<?php echo $countF ?>"></th>
</tr>
<tr>
<th>Male </th>
<th>Female</th>
</tr>
</table>
<br>
Left handed or right handed <?php echo $count ?> Entries
<table border=1 cellpadding=0 cellspacing=0 bordercolor=#000000>
<tr>
<th valign=bottom><?php echo $countLeft ?></th>
<th valign=bottom><?php echo $countRight ?></th>
</tr>
<tr>
<th valign=bottom><?php printf("%5.1f", 100$countLeft/$count) ?>%</th>
<th valign=bottom><?php printf("%5.1f", 100$countRight/$count) ?>%</th>
</tr>
<tr>
<th valign=bottom><img src=silver.gif width=10 height="<?php echo $countLeft ?>"></th>
<th valign=bottom><img src=silver.gif width=10 height="<?php echo $countRight ?>"></th>
</tr>
<tr>
<th>Left</th>
<th>Right</th>
</tr>
</table>
<br>
Gender with Left or right handed <?php echo $count ?> Entries
<table border=1 cellpadding=0 cellspacing=0 bordercolor=#000000>
<tr>
<th valign=bottom><?php echo $countLeftM ?></th>
<th valign=bottom><?php echo $countRightM ?></th>
<th valign=bottom><?php echo $countLeftF ?></th>
<th valign=bottom><?php echo $countRightF ?></th>
</tr>
<tr>
<th valign=bottom><?php printf("%5.1f", 100$countLeftM/$count) ?>%</th>
<th valign=bottom><?php printf("%5.1f", 100$countRightM/$count) ?>%</th>
<th valign=bottom><?php printf("%5.1f", 100$countLeftF/$count) ?>%</th>
<th valign=bottom><?php printf("%5.1f", 100$countRightF/$count) ?>%</th>
</tr>
<tr>
<th valign=bottom><img src=Purple.gif width=10 height="<?php echo $countLeftM ?>"></th>
<th valign=bottom><img src=purple.gif width=10 height="<?php echo $countRightM ?>"></th>
<th valign=bottom><img src=silver.gif width=10 height="<?php echo $countLeftF ?>"></th>
<th valign=bottom><img src=silver.gif width=10 height="<?php echo $countRightF ?>"></th>
</tr>
<tr>
<th>Left handed Male</th>
<th>Right handed Male</th>
<th>Left handed Female</th>
<th>Right handed Female</th>
</tr>
</table>
<br>
</center>
GRAPH_;
?>