I have an assignment that has a form that takes ID and Last name as inputs. I want to take both the ID and Last Name and match it with the text file. If it matches, show that student in a table. If it doesn't match, echo that the student isn't found. So far, I got almost everything done, but everytime I search a student that exists, the student that isn't found is echoed.

Here is the link to my form: <http://hills.ccsf.edu/~ryan/a7p1.php>

Here is the class of students that you can get the ID and Last name from. The first column is the Student ID and the second column is the Last Name: <http://fog.ccsf.edu/~tboegel/showclass.php>

Here is the code:

```
<?php                                                                                                                      

$lname = $_REQUEST['lname'];                                                                                               
$id = $_REQUEST['id'];

function DisplayRow($ID) {                                                                                                 
    print "<tr>\n";
    $parts = split(":", $ID);                                                                                              
    for($i=0; $i <=7; $i++) {                                                                                              
    print "<td>$parts[$i]</td>\n";                                                                                     
    }
    print "</tr>\n";                                                                                                       
}

$handle = fopen("class.txt", "r");                                                                                         
$line = fgets($handle);
while(!feof($handle)) {                                                                                                    
    $part = explode(":", $line);                                                                                           
    if($id == $part[0] && $lname == $part[1]) {                                                                            
        echo "<table border='1' width='95%'>                  
        <tr>                                                                                                               
          <th>Student ID</th>                                                                                                
          <th>Student Last Name</th>                                                                                         
          <th>Student First Name</th>
          <th>Midterm 1</th>                                                                                                 
          <th>Midterm 2</th>
          <th>Midterm 3</th>
          <th>Final Exam</th>                                                                                                
          <th>Letter Grade</th>
        </tr>";
        DisplayRow($line);
    } else {
        print "The person you are trying to search for does not exist";
        die;
    }
    $line = fgets($handle);
}
fclose($handle);
print "</table>\n";
?>

```