学生信息表及详细信息页面
Student.php
namespace APP\Http\Controllers;
class Student{
public static $students=[
//导入学生信息
];
}
Usercontroller.php
public function index()
{
//
$students=Student::$students;
return view('admin.Info')->with(compact('students'));
}
public function show($id)
{
//
$stu=null;
$students=Student::$students;
foreach ($students as $value){
if($value['xh']==$id){
$stu=$value;
}
}
return view('detail',compact('stu'));
}
Infor.blade.php
<body>
<table border="1" style="border-collapse:collapse" >
<tr align="center">
<th>编号</th>
<th>学号</th>
<th>姓名</th>
<th>专业</th>
<th>班级</th>
<th>性别</th>
</tr>
@foreach ($students as $item)
@if ($loop->index%2)
<tr class="bgcolor" align="center" >
@else
<tr align="center" >
@endif
<td>{
{
$item['id']}} </td>
<td>{
{
$item['xh']}} </td>
<td><a href="{
{route('user.show',$item['xh'])}}">{
{
$item['xingming']}}</a></td>
<td>{
{
$item['zhuanye']}}</td>
<td>{
{
$item['banji']}}</td>
<td>{
{
$item['xingbie']}}</td>
</tr>
@endforeach
</table>
<style type="text/css">
.bgcolor{
background-color: lightseagreen;
}
</style>
</body>
detail.blade.php
<html>
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" type="text/css" href="{
{asset('bootstrap.min.css')}}">
</head>
<body>
<div class="col-md-8">
<table class="table table-hover table2" >
<caption><h3 align="center">信息学院</h3></caption>
<tr>
<th>学号</th>
<th>姓名</th>
<th>性别</th>
<th>年级</th>
<th>专业</th>
<th>班级</th>
</tr>
<tr >
@if (empty($stu))
<h2 align="center">没有该学生信息!</h2>
@else
<td >{
{
$stu['xh']}} </td>
<td>{
{
$stu['xingming']}}</td>
<td>{
{
$stu['xingbie']}}</td>
<td>{
{
$stu['nianji']}}</td>
<td>{
{
$stu['zhuanye']}}</td>
<td>{
{
$stu['banji']}}</td>
@endif
</tr>
</table>
</div>
<style type="text/css">
.table2 th {
background-color:lightseagreen;
color:black;
}
.table2 td{
background-color: lightblue;
}
</style>
</body>
</html>
详细信息页面