您的位置:首页 > Web前端 > CSS

数据库课程设计(php+html+css)

2017-07-21 20:47 639 查看
折腾了很久的课程设计……既然上了CSDN干脆也贴上来得了,如果以后有人和我用同一种语言,还能参考一下……

主要贴连接数据库的部分和首页。

数据库连接:

<?php @session_start();
ini_set("display_errors","Off");
ini_set("session.cookie_httponly", 1);
header('X-Frame-Options:SAMEORIGIN');

global $mysqli;

if(($mysqli=mysqli_connect("localhost","root",""))==null) //root和后面为空的那个分别是数据库的用户名和密码,使用时要按照你的数据库来修改
die('Could not connect: ' . mysqli_error($mysqli));//连接不上数据库
// use db
mysqli_query($mysqli,"set names utf8");
//if(!$OJ_SAE)mysqli_set_charset("utf8");

if(!mysqli_select_db($mysqli,"student")) //student是你要使用的数据库的名字,使用时也要按自己的修改
die('Can\'t use foo : ' . mysqli_error($mysqli));//找不到名为student的库

//sychronize php and mysql server with timezone settings, dafault setting for China
//if you are not from China, comment out these two lines or modify them.
date_default_timezone_set("PRC");
mysqli_query($mysqli,"SET time_zone ='+8:00'");
?>


首页:(有很多美化界面的语句)

<!doctpye html>
<html lang ="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

<!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

<!-- 可选的 Bootstrap 主题文件(一般不用引入) -->
<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">

<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
<script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css">

<title>学生公寓管理</title>
<style type="text/css">
//    body {background-image:url(/a.jpg);}
p.dashed {border-style: dashed}
</style>

</head>

<center>
<body>
<div class='container'>
<hr>
<h1 style="font-family:verdana;opacity:0.5;background-color:#F4A460;color:red"><p class="dashed">学生公寓管理</p></h1>
<a class='btn btn-info' aria-hidden="true" href="tile.php"><span class="glyphicon glyphicon-refresh" aria-hidden="true"></span>刷新</a>
<a class='btn btn-warning' href="add.php"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span>添加</a>
<a class='btn btn-primary' href="search.php"><span class="glyphicon glyphicon-search" aria-hidden="true"></span>查询</a>
<hr>

<table class='table table-striped'>
<tr>
<th width="100">宿舍号</th>
<th width="150">学生人数</th>
<th width="100">宿舍长</th>
<th width="150">联系方式</th>
<th width="100">水电费(元)</th>
<th width="150">卫生检查</th>
<th width="100">操作</th>
</tr>
<?php
require_once("mysql_conn.php");//导入数据库

$sql = "select * from stu_info";

$result = mysqli_query($mysqli,$sql);

if($result && mysqli_num_rows($result) > 0){
while($rows = mysqli_fetch_array($result)){
echo '<tr>';
echo '<td width="100">'.$rows['id'].'</td>';
echo '<td width="150">'.$rows['num'].'</td>';
echo '<td width="100">'.$rows['name'].'</td>';
echo '<td width="150">'.$rows['phone'].'</td>';
echo '<td width="100">'.$rows['mom'].'</td>';
echo '<td width="150">'.$rows['Flag'].'</td>';
echo '<td width="100">';
echo '<a href="edit.php?id='.$rows['id'].'">编辑</a>';
echo ' <a href="delete.php?id='.$rows['id'].'">删除</a>';
echo '</td>';
echo '</tr>';
}
}
else{
echo '读取失败...</br>';
}

?>

</table>

</center>

</div>

</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: