php - 检查学生是否正在上课
问题描述
这是我的代码。我想检查学生是否正在上课。现在它应该显示哪个学生没有上课时会打印“No student with that 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!";
}
?>
解决方案
推荐阅读
- python - 如何从 QMainWindow 打开一个单独的 UI 窗口?
- ios - 核心数据,获取某个布尔值属性的总和
- laravel - Laravel firstOrCreate 没有 Eloquent
- r - ggplot直方图中的BinSize
- ruby-on-rails - 当你有 mongodb 时应该使用 rake db:migrate
- python - 根据 iat 值填充数据框中的列
- julia - 在 julia 中使用 vcat 时避免内存分配
- javascript - 在 ReactJS 中使用 jQuery 是一种不好的做法吗?
- rpy2 - rpy2 glmnet 获取具有行名的系数
- java - 在 IntelliJ 中使用 Code Iris 创建图形会为一个项目引发 NullPointerException,但不会为另一个项目引发 NullPointerException