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

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

HOW to get the bind variables list.
I've the following problem : I've some SQL queries stored in my DB as VARCHAR2 values.
I need t

Problem with array max size.
Hi to everyone,
I've got a homework about filling a bidimensional array un spiral shape, I alre

session variable problem
Session variable is not working in Fire fox i am getting null value but it is working fine in IE.

Count of reciepients in php mailer
How can i sent a mail to large no of reciepients say 10,00,00 Using PHP MAILER

New to Arrays
Hi I am new to PHP (a week and a half now) and I am just beginning to read about arrays. I understan

Files in current folder. Should be an easy fix.
Never mind. I've asked about this before and just found my answer. Anyway to delete this?

max() problem
I have a while loop to get image names.
Code: $imagequery = mysql_query("SELECT * FROM ad_i

Calander layout
Hi i know this sounds like a simple question but i cant find the answer to it anywhere i have added

Help with Contact Form
I have this Form on an html page and the associated code on page.php (below).
I keep getting the

Timer control causing error
I recently decided to add a timer control to an existing page that uses AJAX on my site. As soon as

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