基本信息
源码名称:员工信息管理系统[含有数据库源码]
源码大小:0.76M
文件格式:.rar
开发语言:PHP
更新时间:2021-06-26
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 2 元 
   源码介绍


<?php
//连接MYSQL服务器,连接数据库
$conn=mysqli_connect("localhost","root","","php") or die("连接数据库失败!".mysqli_error());
//设置数据库编码格式UTF8
mysqli_query($conn,"set names utf8");
//执行查询语句
$result=mysqli_query($conn,"select * from emp_info order by e_id desc");
//获取查询条数
$number=mysqli_num_rows($result);
//引入模板
include_once('index.html');
?>

<?php
    //连接MySQL服务器,选择数据库
    $link = mysqli_connect("localhost", "root", "123456", "php") or die("连接数据库服务器失败!".mysqli_error());
    mysqli_query($link,"set names utf8");//设置数据库编码格式utf8
    $id    = $_GET['e_id'];   //获取id
    $query = 'select * from emp_info where e_id ='.$id;
    $result = mysqli_query($link,$query); // 执行查询语句
    $data   = mysqli_fetch_assoc($result);  //获取关联数组形式的结果集
    include_once('editPeople.html');              //引入模板

<?php
    /* 连接数据库 */
    $link = mysqli_connect('localhost','root','','php');
    if(!$link){
        die('mysqli connect error:'.mysqli_connect_error());
    }
    $e_id    = $_GET['e_id']; //获取id
    $query = "delete from emp_info where e_id = ".$e_id;   //SQL删除语句
    /* 判断删除成功或失败 */
    if(mysqli_query($link,$query) === true ){
        echo "<script>alert('删除成功');window.location.href='index.php'</script>";
    }else{
        echo "<script>alert('删除失败');</script>";
    }


<?php
/* 获取POST提交数据 */
$e_id       = $_POST['e_id'];
$e_name     = $_POST['e_name'];
$e_dept = $_POST['e_dept'];
$date_of_birth    = $_POST['date_of_birth'];
$date_of_entry = $_POST['date_of_entry'];

$link = mysqli_connect('localhost', 'root', '', 'php');
mysqli_query($link,"set names utf8");//设置数据库编码格式utf8
/* 检测连接是否成功 */
if (!$link) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}
/* 检测是否生成MySQLi_STMT类 */
$query = "update emp_info set e_name = ?,e_dept = ? ,date_of_birth = ? ,date_of_entry = ? where e_id = ".$e_id;
$stmt  = mysqli_prepare($link, $query);
if ( !$stmt ) {
    die('mysqli error: '.mysqli_error($link));
}
/* 参数绑定 */
mysqli_stmt_bind_param($stmt, 'ssds', $e_name, $e_dept, $date_of_birth, $date_of_entry);
/* 执行prepare语句 */
mysqli_stmt_execute($stmt);
/* 根据执行结果,跳转页面 */
if(mysqli_stmt_affected_rows($stmt)){
    echo "<script>alert('修改成功');window.location.href='index.php';</script>";
}else{
    echo "<script>alert('修改失败');</script>";
}

?>