设为首页 加入收藏

TOP

PHP 结合 Bootstrap 实现学生列表以及添加学生功能实现(继上篇登录及注册功能之后)(一)
2019-08-15 23:29:49 】 浏览:34
Tags:PHP 结合 Bootstrap 实现 学生 以及 添加 功能 上篇 登录 注册 之后

本人是一位学生,正在学习当中,可能BUG众多,请见谅并指正,谢谢!!!

 

 

学生列表实现

HTML:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>学生信息</title>
    <link rel="stylesheet" type="text/css" href="css/Bootstrap.css">
</head>
<body>
    <div class="container mt-5">
        <h1 class="display-4 text-center">学生信息管理中心</h1>
        <div class="row mt-3">
            <a class="btn btn-info col-sm-2" style="margin-right: 88px; margin-left: 15px;" href="add_student.php">添加学生</a>
            <input type="text" class="form-control col-sm-6 ml-5" placeholder="请输入关键词">
              <button type="submit" class="btn btn-info col-sm-2 ml-4">点击搜索</button>
        </div>
        <table class="table table-hover table-bordered mt-3">
            <thead class="thead-inverse">
                <tr>
                    <th class="text-center align-middle">学号</th>
                    <th class="text-center align-middle">学院/系</th>
                    <th class="text-center align-middle">班级</th>
                    <th class="text-center align-middle">姓名</th>
                    <th class="text-center align-middle">性别</th>
                    <th class="text-center align-middle">年龄</th>
                    <th class="text-center align-middle">照片</th>
                    <th class="text-center align-middle">操作</th>
                </tr>
            </thead>
            <tbody class="text-center">
            <?php while ($student = mysqli_fetch_assoc($query)): ?>
                <tr>
                    <td class="align-middle"><?php echo $student['num']; ?></td>
                    <td class="align-middle"><?php echo $student['system']; ?></td>
                    <td class="align-middle"><?php echo $student['class']; ?></td>
                    <td class="align-middle"><?php echo $student['name']; ?></td>
                    <td class="align-middle"><?php echo $student['gender'] === 1 ? '♂' : '♀'; ?></td>
                    <td class="align-middle"><?php echo date('Y') - substr($student['birthday'], 0, 4); ?></td>
                    <td class="align-middle"><img src="<?php echo $student['photo']; ?>" width="100" height="70"></td>
                    <td class="align-middle"><a class="btn btn-info mr-2" href="edit.php?num=<?php echo $student['num']; ?>">编辑</a><a class="btn btn-danger ml-2" href="delete.php?num=<?php echo $student['num']; ?>">删除</a></td>
                </tr>
            <?php endwhile ?>
            </tbody>
        </table>
    </div>
</body>
</html>

PHP:

// 这里:
// 第一个参数:本地网络地址
// 第二个参数:数据库账号
// 第三个参数:数据库密码
// 第四个参数:数据库名称
$connection
= mysqli_connect('localhost', 'root', '密码', 'students_info_system'); if (!$connection) { exit('<h1>连接数据库失败</h1>'); } $query = mysqli_query($connection, 'selec
首页 上一页 1 2 3 下一页 尾页 1/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇PSR - PHP标准推荐 下一篇Redis面试总结

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目