help with calculations on a flat text file


Posted on 16th Feb 2014 07:03 pm by admin

hello,
I have this code below that is attached to a flat file like this:
Email:LastName:FirstName:Assignment1,100:Assignment2,100:Quiz1,50
someone@email.com:Doe:John:85:93:45
Did you know?Explore Trending and Topic pages for more stories like this.

Here is the code:
<?php
$row=1;
$handle= fopen($full_file,'r');
$heading=True;
echo '<table>';
$data=fgetcsv($handle,1024,":");
echo '<tr>';
foreach ($data as $cell)
{
echo '<th>' .$cell. '</th>';
}

echo '<th>Overall Average</th>';
echo '</tr>';

while (($data=fgetcsv($handle,1024,":")) !==FALSE)
{
echo '<tr>';
foreach($data as $cell)
{
$average=$cell/100;
echo '<td width="50">' .$cell. ' ' .$average. '</td>';


}

//echo '<td></td>';


}
if ($row==1)
{
$heading=False;
}
$row++;
echo '</tr>';



echo '</table>';
fclose($handle);
?>

what i need to do with this code, is have an extra column added at the end where is averages out the student's scores, based on the weight of the grade that is located on row 1 and delimited by a ",".

Please help.
No comments posted yet

Your Answer:

Login to answer
67 Like 32 Dislike
Previous forums Next forums
Other forums

PHP File Upload Problem
Hi, I have written a very simple file upload script but it fails for reasons I can't explain. Hope

Multiple Options for a Single Page
For this example I want to use the Handlers option which is under Fed Admin and all the related codi

PHP hyperlinks generator
Hi

I need some help to get this done using php:


1 - I have few hyperlinks say 500

rdns with php
I am trying to build a script that will show all of the different domains that are hosted on the sam

Help to integrate whois Domain Details to website
Hi,

can i know is their any php script r methods to add domain details to my website.

Upload file!
Ok i have a form..
Code: <form name="form1" method="post" action=&quo

MSSQL/PHP
I am tryint to setup a webapplication developed in PHP, Apache2.0 and SQLServer2000 as backend which

Stopped working!
So I had to change some stuff, none of it major. Stuff like the extension_dir and such. BEFORE I did

sql problems
I am having a small problem with my sql statement. it is inserting into 4 of the fields.

fie

value not going in data base
hello friends....
i am having a working javascript....when i am selecting any

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash