这是我的代码。我想检查一个学生是否正在上课。现在,它应该显示“没有那个ID的学生”时应显示哪个没有上课。
<?php
$students = "students.txt";
$id = $_GET['student'];
$line = file($students);
$i=0;
$string_line_array = explode('|', $line[0]);
$fp=@fopen($students, r);
if(is_resource($fp))
{
while(@!fgets($line[$i]))
{
$string_line_array = explode('|', $line[$i]);
if($string_line_array[0] == $id)
{
if($string_line_array[2] == 0)
{
echo $string_line_array[1]."(".$string_line_array[0]."): "."hasn\'t signed up";
break;
}
else
{
echo $string_line_array[1]."(".$string_line_array[0]."): "."has signed up";
break;
}
}
else
{
echo "No students with that id!";
}
$i++;
}
}
else
{
echo "Error!";
}
?>