Jump to content


Photo

Trouble with file editing???


  • Please log in to reply
1 reply to this topic

#1 jeaker

jeaker
  • Members
  • PipPipPip
  • Advanced Member
  • 36 posts

Posted 26 October 2006 - 05:13 AM

I want to be able to allow the user to pull in the file grades.txt for editing. The user should be allowed to add a name a series of grades, change grades on existing data, or add grades to an existing student. I want to use -2 as the end of file indicater and -1 as the end of line mark.
(ex. john
doe
23
34
98
-1
jane
doe
21
32
-2)
If anyone can help me with this it will be greatly appreciated and thanks sooo much in advance.
Here is some code that i have gotten together so far.
<html>
<head>
<title>Edit Student Data</title>
</head>
<body>
<?php
$line = file("Grades.txt");
$i = 0;
$num = 0;
$cnt = 0;
while ($line[$i] != -2) {
      $first = $line[$i];
      $i++;
      $last = $line[$i];
      $i++;
   while ($line[$i] != -1) {
         $num = $num + $line[$i];
         $cnt++;
         $i++;
         }
$num = $cnt > 0 ? $num / $cnt : 0;
echo "$last, $first, $num<br />";
$i++;
$cnt = 0;
$num = 0;
}
?>


#2 php_joe

php_joe
  • Members
  • PipPipPip
  • Advanced Member
  • 175 posts

Posted 26 October 2006 - 04:01 PM

***post removed by Joe***
[url=http://darkswordsguide.com][/url]




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users