I have two problems.
I want to input an id and name from a form and check if both items exist as keys within an array. So far all I get is my warning echoed back.
My warning gets echoed back four times, I don't know why.
here is my code:
<?php
//value specifies which text file to open
$class = $HTTP_POST_VARS['class'];
//name of student
$name = $HTTP_POST_VARS['name'];
//student's id
$id = $HTTP_POST_VARS['id'];
//open file into an array by lines
$file = file ("$class");
//file into array by lines
foreach( $file as $line ) {
//split by tabs
$data = explode("\t", $line);
//the [1] will be your id
if ( $id == $data[1] && array_key_exists($name, $data[0]) ) {
print "<table>\n
<tr><th>Name</th>
<th>ID Number</th>
<th>Your Points</th>
<th>Possible Points</th>
<th>Percentage</th>
<th>Grade</th>
</tr>\n
<tr><td>{$data[0]}</td>
<td align='center'>{$data[1]}</td>
<td align='center'>{$data[2]}</td>
<td align='center'>{$data[3]}</td>
<td align='center'>{$data[4]}</td>
<td align='center'>{$data[5]}</td>
</tr>\n
</table>";
} else { print "Wrong"; }
}
?>