PHP search for student ID and last name
<p>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.</p>

<p>Here is the link to my form: <a href="http://hills.ccsf.edu/~ryan/a7p1.php" rel="nofollow">http://hills.ccsf.edu/~ryan/a7p1.php</a></p>

<p>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: <a href="http://fog.ccsf.edu/~tboegel/showclass.php" rel="nofollow">http://fog.ccsf.edu/~tboegel/showclass.php</a></p>

<p>Here is the code:</p>

<pre><code>&lt;?php                                                                                                                      

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

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

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