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

Casting Decimals in Oracle
This code worked as a query in DB2, but I am not sure what the syntax is for casting decimals in Ora

simple script won't work. Please help
I'm new to php, and I am having trouble displaying a simple script in my web browser. My php code ex

Creating web pages by php
Hello again,
I was just wondering us there a way to use a php script to create a new web page. I

Change image filetype on upload?
Hi,
I've got a form which uploads an image to the server.
Is it possible to change the image t

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

Create or replace package is ending ORA-21700
Database 9.2.0., patch 8 (9.2.0.8.0).
I trying run
create or replace package ....etc.

Tracking Unique Clicks
Hi guys and gals,

Basically I have a database which tracks clicks on my outbound links, I do

Why is my row count 0?
Here's the MySQL query i'm running. It basically pulls data from 2 tables based on some data passed.

how to export excel file in same server
My first post - php newbie, so appreciate your support.

I'm currently using headers to save w

whats wrong with my code please help!!!
this is the error


Warning: mysql_close(): supplied argument is not a valid MySQL-Link res

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