数据库课程设计(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>
相关文章推荐
- 韩顺平_轻松搞定网页设计(html+css+javascript)_ 第18讲_js课程介绍_js基本介绍_学习笔记_源代码图解_PPT文档整理
- 利用html、css、javascript、php同时交互数据库制作的注册登录界面
- 网页设计高手必备:HTML、CSS、Javascript教程资料
- PHP页面显示乱码处理(数据库、html页面、服务器php页面编码)
- PHP 杂谈《重构-改善既有代码的设计》之五 简化函数调用【链接:http://www.cnblogs.com/baochuan/archive/2012/04/10/2437688.html】
- 数据库课程设计——宾馆管理系统UML协作图
- 韩顺平_轻松搞定网页设计(html+css+javascript)_第27讲_js一维数组_一维数组细节_学习笔记_源代码图解_PPT文档整理
- PHP安全之数据库安全——设计、连接和加密
- Ajax动态访问数据库设计html多级select下拉菜单的方法
- 通达OA 小飞鱼老师OA工作流设计课程教学网络公开课之HTML基础(一)
- 手机web――自适应网页设计(html/css控制)
- 数据库课程设计心得【6】----总结篇
- 如何从数据库调出数据显示到页面 PHP+Mysql+Html
- HTML+CSS基础课程之CSS基础代码语法
- Html-DW(4)div & css 设计head底部横条内容
- Codecademy上的HTML/CSS课程知识点总结(一)
- php面试题之一——HTML+CSS(基础部分)
- 数据库课程设计——羽晴YuQ3,物资管理系统
- 一、HTML和CSS基础--HTML+CSS基础课程--第1部分