完成前端页面
登入成功之后 可以注销
1.实现导航栏
在这之前说一下sessionID
session
session:用户发送请求,服务器生成一个session对象,存放服务器端的文件里,同时把sessionID传给客户端,保存到客户端的Cookie文件里
设置session——多文件共享数据session作用。可以跟踪特定用户的信息
比如用户登录后在网站显示用户名,购物车等
必须先set否则get里得不到
session相关配置**:php.ini**文件
在wampserver的PHP文件夹的php.ini里
session生命周期/有效时间1.访问网站开始2.调用session_destroy结束3.或者session.gc4_max、lifetime=1440(后面时间需要设置,确定超出多少时间不再响应)4.关闭浏览器
必须登录才能访问/没有登录不能访问——session判断
使用
set.php
<?php
if (!isset($_SESSION["admin"]))
header("localhost:index.php");
$username="wsw";
session_start();
$_SESSION["name"]=$username;
?>
get.php
session_unset();//清空session但是客户端的session文件在里面的数据没有
session_destroy();//删除session,文件不在存在。但当前页能够获取session数据
<?php
//取session
session_start();
//session_unset();//清空session但是客户端的session文件在里面的数据没有
//session_destroy();//删除session,文件不在存在。但当前页能够获取session数据
echo $_SESSION["name"];
?>
效果:先在浏览器中打开set.php再打开get.php会出现输入的session“wsw”
php文件下php.ini文件 cookie,tmp存session信息看今天的文件存的Alice
实现这个效果 就是登入的人的名称
文件:neuvideo456/admin/index.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="../../favicon.ico">
<title>管理员登录</title>
<!-- Bootstrap core CSS -->
<link href="assets/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="assets/signin/signin.css" rel="stylesheet">
<!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
<!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
<script src="assets/signin/ie-emulation-modes-warning.js"></script>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="http://cdn.bootcss.com/html5shiv/3.7.0/html5shiv.js"></script>
<script src="http://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="container">
<form class="form-signin" method="post" action="doAdminLogin.php" role="form">
<h2 class="form-signin-heading">欢迎管理员登录</h2>
<input type="text" name="adminname" class="form-control" placeholder="Administrator name" required autofocus>
<input type="password" name="password" class="form-control" placeholder="Password" required>
<div class="checkbox">
<label>
<input type="checkbox" value="remember-me"> Remember me
</label>
</div>
<input class="btn btn-lg btn-primary btn-block" type="submit" value="登录">
</form>
<?php
if (isset($_GET["err"])){
echo "<h2 style='color: brown;margin: 0 40%'>{$_GET["err"]}</h2>";}
?>
</div> <!-- /container -->
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="assets/signin/ie10-viewport-bug-workaround.js"></script>
</body>
</html>
登入文wamp\www\neuvideo456\admin\doAdminLogin.php
<?php
session_start();
$a=$_POST["adminname"];//admin
$b=$_POST["password"];//psw
$sql="select * from admins WHERE adminname='$a' AND password=md5('$b')";
//在admins表中添加数据在数据库中
require ("inc_admin.php");
$con = connect();
$rs=mysqli_query($con,$sql);
if (mysqli_num_rows($rs)){
$row=mysqli_fetch_array($rs);
$_SESSION["admin"]=$a;//存入用户名session
$_SESSION["adminid"]=$row["adminid"];//后面是数据库中的名字
header("location:welcome.php");
}else{
header("location:index.php?err=用户名密码错误!");//查看index是登入页,传的参数是输入错误信息才出现
}
?>
用到表admins
在数据库中查找该表
这是你添加的管理员身份,但是密码是看不到的
现在在index.php文件中用管理员身份登入就能进去,跳到welcome.php文件显示管理员名称
welcome.php
<?php
//session_start();//启动session
require_once('tpl/header.php');//header里有session_start
?>
<NAV class="navbar navbar-inverse navbar-fixed-top">
<DIV class="container-fluid">
<DIV class="navbar-header"><BUTTON class="navbar-toggle collapsed"
aria-expanded="false" aria-controls="navbar" type="button" data-toggle="collapse"
data-target="#navbar"><SPAN class="sr-only">Toggle navigation</SPAN>
<SPAN class="icon-bar"></SPAN><SPAN class="icon-bar"></SPAN><SPAN class="icon-bar"></SPAN></BUTTON>
<A class="navbar-brand" href="#" target="_blank">视频信息管理系统</A>
</DIV>
<DIV class="navbar-collapse collapse" id="navbar">
<UL class="nav navbar-nav navbar-right">
<LI><A
href="logout.php">注销</A></LI></UL></DIV></DIV></NAV>
<DIV class="container-fluid">
<DIV class="row row-offcanvas row-offcanvas-left">
<DIV class="col-xs-6 col-sm-3 col-md-2 sidebar sidebar-offcanvas" id="sidebar">
<UL class="nav nav-sidebar">
<LI><A class="accordion-toggle collapsed" href="typeList.php" data-toggle="collapse" data-target="#mastersubmenu">视频类型维护</A>
<UL class="nav collapse" id="mastersubmenu" style="padding-left: 20px;">
<LI><A href="typeAdd.php">添加视频类型</A></LI>
<LI><A href="typeList.php">查询视频类型</A></LI>
</UL>
</LI>
<LI><A class="accordion-toggle collapsed" href="videoList.php" data-toggle="collapse" data-target="#mastersubmenu1">视频信息维护</A>
<UL class="nav collapse" id="mastersubmenu1" style="padding-left: 20px;">
<LI><A href="videoAdd.php">添加视频信息</A></LI>
<LI><A href="videoList.php">查询视频信息</A></LI>
</UL>
</LI>
<LI><A href="commentList.php">留言维护</A></LI>
<LI><A href="userList.php">用户维护</A></LI>
<LI><A href="changePassword.php">密码维护</A></LI>
</UL>
</DIV>
<DIV class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main ">
<P class="pull-left visible-xs"><BUTTON class="btn btn-primary btn-xs" type="button"
data-toggle="offcanvas">Toggle</BUTTON> </P> <br> <br>
<div class="jumbotron">
<h2>欢迎管理员: <?php echo $_SESSION["admin"];?>访问"视频信息管理系统"</h2>
<br>
<br>
<p>计算机科学与技术团队 PHP课程组</p>
<P>办公室 A3-118</p>
<p>办公电话 84835205</p>
<p><a href="mailto:zhouhaibo@neusoft.edu.cn">意见箱</a></p>
</div>
<?php
require_once('tpl/footer.php');
?>
效果
实现用户登入的登入和注销功能
写法不要太近 <?php } ?>
neuvideo456/tpl/head.php中的登入和注销
<ul class="nav navbar-nav navbar-right">
<!-- 模态框-->
<?php if (!isset($_SESSION["user"])){?>
<li><a href="#" data-toggle="modal" data-target="#login">登录</a></li>
<li><a href="#" data-toggle="modal" data-target="#reg">注册</a></li>
<?php }else{ ?>
<!-- data-toggle="modal" data-target="#login"-->
<li><a href="#">欢迎<?php echo $_SESSION["user"];?></a></li>
<!-- data-toggle="modal" data-target="#logout"-->
<li><a href="logout.php" >注销</a></li>
<?php } ?>
</ul>
注意一点:这里代码要实现先后台分离。href="logout.php"要在index.php一层的位置调用。
logout.php(注销)
<?php
//注销 清除session,回到登录页
session_start();
session_unset();//取不到session数据退出
session_destroy();
header("location:index.php");
//左连接右链接是外联。一般用坐莲,join是内内连接
?>
doLogin.php
<?php
session_start();
$a=$_POST["username"];//admin
$b=$_POST["pswd"];//psw
$sql="select * from users WHERE uname='$a' AND password=md5('$b')";
//在admins表中添加数据在数据库中
require ("system/dbConn.php");
$con = connect();
$rs=mysqli_query($con,$sql);
if (mysqli_num_rows($rs)){
$row=mysqli_fetch_array($rs);
$_SESSION["user"]=$a;//存入用户名session
$_SESSION["uid"]=$row["uid"];//后面是数据库中的名字
header("location:index.php");
}else{
header("location:index.php?err=用户名密码错误!");//查看index是登入页,传的参数是输入错误信息才出现
}
?>
管理员登入的时候还有个判断是不是有权访问
loginCheck.php
<!-- loginCheck.php -->
<?php
session_start();
if(!isset($_SESSION["admin"]))
header("location:index.php?msg2=您没有权限!");
// header("location:index.php?err=2");
?>
用户登入的水平导航 是根据你数据库typename的字段显示的
左连接右链接是外联。一般用坐莲,join是内内连接
<?php
require_once("./system/dbConn.php");
// require_once("../system/myFunc.php");
$con=connect();
//表连接(videotype的内容全部输出,以他为左)
$sql="select t.tid,typename,count(vid) cv from videotype t LEFT JOIN videos v ON t.tid=v.tid GROUP BY t.typename";
$rs=mysqli_query($con,$sql);
?>
<ul class="nav navbar-nav">
<li><a href="index.php">首页</a></li>
<?php while( $row = mysqli_fetch_array($rs)) { ?>
<li><a href="list.php?tid=<?php echo $row["tid"];?>">
<?php echo $row["typename"];?>(<?php echo $row["cv"]; ?>)
</a>
</li>
<?php } ?>
</ul>
neuvideo456/tpl/head.php完整
<?php
session_start();
?>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="../../favicon.ico">
<title>视频信息管理系统</title>
<!-- Bootstrap core CSS -->
<link href="assets/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="assets/css/offcanvas.css" rel="stylesheet">
<link href="assets/css/style.css" rel="stylesheet">
<!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
<!--[if lt IE 9]>
<script src="assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
<script src="assets/js/ie-emulation-modes-warning.js"></script>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="http://cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="http://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<nav class="navbar navbar-fixed-top navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<?php
require_once("./system/dbConn.php");
// require_once("../system/myFunc.php");
$con=connect();
//表连接(videotype的内容全部输出,以他为左)
$sql="select t.tid,typename,count(vid) cv from videotype t LEFT JOIN videos v ON t.tid=v.tid GROUP BY t.typename";
$rs=mysqli_query($con,$sql);
?>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li><a href="index.php">首页</a></li>
<?php while( $row = mysqli_fetch_array($rs)) { ?>
<li><a href="list.php?tid=<?php echo $row["tid"];?>">
<?php echo $row["typename"];?>(<?php echo $row["cv"]; ?>)
</a></li>
<?php } ?>
</ul>
<form class="navbar-form navbar-left" role="search" action="search.php">
<div class="form-group">
<input type="text" class="form-control" placeholder="Search">
</div>
<button type="submit" class="btn btn-default">搜索</button>
</form>
<ul class="nav navbar-nav navbar-right">
<!-- 模态框-->
<?php if (!isset($_SESSION["user"])){?>
<li><a href="#" data-toggle="modal" data-target="#login">登录</a></li>
<li><a href="#" data-toggle="modal" data-target="#reg">注册</a></li>
<?php }else{ ?>
<!-- data-toggle="modal" data-target="#login"-->
<li><a href="#">欢迎<?php echo $_SESSION["user"];?></a></li>
<!-- data-toggle="modal" data-target="#logout"-->
<li><a href="logout.php" >注销</a></li>
<?php } ?>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
<!-- /.navbar -->
<!-- /注册模态框 -->
<div class="modal fade" id="reg" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">registration</h4>
</div>
<div class="modal-body">
<form method="post" action="doUserReg.php" enctype="multipart/form-data" class="form-horizontal">
<div class="form-group">
<label for="exampleInputUserName" class="col-md-2 control-label">用户</label>
<div class="col-md-10">
<input type="text" name="username" class="form-control" id="exampleInputUserName" placeholder="姓名" required="">
</div>
</div>
<div class="form-group">
<label for="exampleInputPassword" class="col-md-2 control-label">密码</label>
<div class="col-md-10">
<input type="password" name="password" class="form-control" id="exampleInputPassword" placeholder="密码" required="">
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label">性别</label>
<div class="col-md-10">
<label class="radio-inline">
<input type="radio" name="gender" value="0" checked=""> 男
</label>
<label class="radio-inline">
<input type="radio" name="gender" value="1"> 女
</label>
</div>
</div>
<div class="form-group">
<label for="exampleInputBirth" class="col-md-2 control-label">生日</label>
<div class="col-md-10">
<input type="date" name="birthdate" class="form-control" id="exampleInputBirth" placeholder="生日" required="">
</div>
</div>
<div class="form-group">
<label for="exampleInputFile" class="col-md-2 control-label">头像</label>
<div class="col-md-10">
<input type="file" name="pic" id="exampleInputFile" required="">
</div>
</div>
<div class="form-group">
<label for="exampleInputEmail" class="col-md-2 control-label">电子邮件</label>
<div class="col-md-10">
<input type="email" name="email" class="form-control" id="exampleInputEmail" placeholder="常用邮箱" required="">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<input type="submit" class="btn btn-default" value="注册">
<input type="reset" class="btn btn-default" value="重置">
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" onclick="location.replace('index.php')" data-dismiss="modal">关闭</button>
</div>
</div>
</div>
</div>
<!-- /注册模态框结束 -->
<!-- /登录模态框开始 -->
<div class="modal fade" id="login" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">user login</h4>
</div>
<div class="modal-body">
<form name="fm" method="post" action="doLogin.php" onsubmit="return check()" class="form-horizontal">
<input type="hidden" name="vid" id="videoid" >
<div class="form-group">
<label for="exampleInputUserName1" class="col-md-2 control-label">用户名</label>
<div class="col-md-4">
<input type="text" name="username" class="form-control" id="exampleInputUserName1" placeholder="姓名" required>
</div>
<div class="col-md-6">
</div>
</div>
<div class="form-group">
<label for="exampleInputPassword1" class="col-md-2 control-label">密码</label>
<div class="col-md-4">
<input type="password" name="pswd" class="form-control" id="exampleInputPassword1" placeholder="密码" required>
</div>
<div class="col-md-6">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<input type="submit" class="btn btn-default" value="登录">
<input type="reset" class="btn btn-default" value="重置">
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" onclick="location.replace('index.php')" data-dismiss="modal">关闭</button>
</div>
</div>
</div>
</div>
<!-- /登录模态框结束 -->
实现这个功能:
<?php
$sql="select t.tid,typename,count(vid) cv from videotype t LEFT JOIN videos v ON t.tid=v.tid GROUP BY t.typename
ORDER BY cv DESC limit 4";//limit 4 取前4条
$rs=mysqli_query($con,$sql);
//取出热门类型
$tidarr=array();//视频名称
$typenamearr=array();//视频类型
while ($row=mysqli_fetch_array($rs)){
$tidarr[]=$row["tid"];//一维数组,把视频名字放到里面,数组 增加
$typenamearr[]=$row["typename"];//一维数组
}
?>
<div class="col-xs-12 col-sm-9">
<?php
// for循环产生多个栏目
for ($i=0;$i<4;$i++) {
?>
<div class="row text-center">
<div class="col-xs-12 col-lg-12 mlist">
<h2>
<!-- 栏目名称-->
<?php echo $typenamearr[$i]; ?>
</h2>
<ul class="list-inline row text-center">
<?php
$sql="select * from videos WHERE tid = " .$tidarr[$i]. " order by vid desc limit 4";
$rs=mysqli_query($con,$sql);//得到结果集
while ($row=mysqli_fetch_array($rs)){
?>
<li class="col-xs-4 col-sm-3 col-lg-2">
<!-- 显示视频的图片-->
<img src="posters/<?php echo $row["pic"];?>" class="responsive img-thumbnail"/>
<!-- 视频标题-->
<p><a href="show.php?vid=<?php echo $row["vid"];?>">
<!-- 视频标题-->
<?php echo $row["videoname"];?>
</a>
</p>
</li>
<?php } ?>
</ul>
<p><a class="btn btn-default" href="list.php?tid=<?php echo $tidarr[$i]; ?>" role="button">更多 »</a></p>
</div>
<!--/.col-xs-6.col-lg-4-->
</div>
<!--/row-->
<?php } ?>
</div>
右侧排行不需要for循环
-
$sql="select * from videos order by hittimes desc limit 4";
-
$rs=mysqli_query($con,$sql);
-
while ($row=mysqli_fetch_array($rs)){ ?>
-
<img src="posters/<?php echo $row["pic"];?>"
-
<?php echo $row["videoname"];?> 视频标题-->
<div class="col-xs-6 col-sm-3 sidebar-offcanvas" id="sidebar">
<div class="list-group text-center">
<!-- --><?php //echo $typenamearr[$i]; ?>
<h2 style="color:white;" >点击排行</h2>
<ul class="list-inline row text-center">
<?php
$sql="select * from videos order by hittimes desc limit 4";
$rs=mysqli_query($con,$sql);//得到结果集
while ($row=mysqli_fetch_array($rs)){
?>
<li class="col-xs-12 col-lg-6">
<img src="posters/<?php echo $row["pic"];?>" class="responsive img-thumbnail"/>
<p><a href="show.php?vid=<?php echo $row["vid"];?>">
<!-- 视频标题-->
<?php echo $row["videoname"];?>
</a>
</p>
</li>
<?php } ?>
</ul>
</div>
完整index.php文件
<?php
require_once('tpl/head.php');
include_once('./system/dbConn.php');
?>
<div class="container">
<!--幻灯片开始-->
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
<li data-target="#carousel-example-generic" data-slide-to="1"></li>
<li data-target="#carousel-example-generic" data-slide-to="2"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner">
<div class="item active">
<img src="assets/images/img4.jpg" class="img-responsive" alt="img4">
</div>
<div class="item">
<img src="assets/images/img2.jpg" class="img-responsive" alt="img2">
</div>
<div class="item">
<img src="assets/images/img3.jpg" class="img-responsive" alt="img3">
</div>
</div>
<!-- Controls -->
<a class="left carousel-control" href="#carousel-example-generic" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
</a>
<a class="right carousel-control" href="#carousel-example-generic" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
</a>
</div>
<!--幻灯片结束-->
<?php
$sql="select t.tid,typename,count(vid) cv from videotype t LEFT JOIN videos v ON t.tid=v.tid GROUP BY t.typename
ORDER BY cv DESC limit 4";//limit 4 取前4条
$rs=mysqli_query($con,$sql);
//取出热门类型
$tidarr=array();//视频名称
$typenamearr=array();//视频类型
while ($row=mysqli_fetch_array($rs)){
$tidarr[]=$row["tid"];//一维数组,把视频名字放到里面,数组 增加
$typenamearr[]=$row["typename"];//一维数组
}
?>
<div class="row row-offcanvas row-offcanvas-right">
<div class="col-xs-12 col-sm-9">
<?php
// for循环产生多个栏目
for ($i=0;$i<4;$i++) {
?>
<div class="row text-center">
<div class="col-xs-12 col-lg-12 mlist">
<h2>
<!-- 栏目名称-->
<?php echo $typenamearr[$i]; ?>
</h2>
<ul class="list-inline row text-center">
<?php
$sql="select * from videos WHERE tid = " .$tidarr[$i]. " order by vid desc limit 4";
$rs=mysqli_query($con,$sql);//得到结果集
while ($row=mysqli_fetch_array($rs)){
?>
<li class="col-xs-4 col-sm-3 col-lg-2">
<!-- 显示视频的图片-->
<img src="posters/<?php echo $row["pic"];?>" class="responsive img-thumbnail"/>
<!-- 视频标题-->
<p><a href="show.php?vid=<?php echo $row["vid"];?>">
<!-- 视频标题-->
<?php echo $row["videoname"];?>
</a>
</p>
</li>
<?php } ?>
</ul>
<p><a class="btn btn-default" href="list.php?tid=<?php echo $tidarr[$i]; ?>" role="button">更多 »</a></p>
</div>
<!--/.col-xs-6.col-lg-4-->
</div>
<!--/row-->
<?php } ?>
</div>
<!--/.col-xs-12.col-sm-9-->
<div class="col-xs-6 col-sm-3 sidebar-offcanvas" id="sidebar">
<div class="list-group text-center">
<!-- --><?php //echo $typenamearr[$i]; ?>
<h2 style="color:white;" >点击排行</h2>
<ul class="list-inline row text-center">
<?php
$sql="select * from videos order by hittimes desc limit 4";
$rs=mysqli_query($con,$sql);//得到结果集
while ($row=mysqli_fetch_array($rs)){
?>
<li class="col-xs-12 col-lg-6">
<img src="posters/<?php echo $row["pic"];?>" class="responsive img-thumbnail"/>
<p><a href="show.php?vid=<?php echo $row["vid"];?>">
<!-- 视频标题-->
<?php echo $row["videoname"];?>
</a>
</p>
</li>
<?php } ?>
</ul>
</div>
<div class="list-group text-center">
<!-- --><?php //echo $typenamearr[$i]; ?>
<h2 style="color:white;" >下载排行</h2>
<ul class="list-inline row text-center">
<?php
$sql="select * from videos order by downtimes desc limit 4";
$rs=mysqli_query($con,$sql);//得到结果集
while ($row=mysqli_fetch_array($rs)){
?>
<li class="col-xs-12 col-lg-6">
<img src="posters/<?php echo $row["pic"];?>" class="responsive img-thumbnail"/>
<p><a href="show.php?vid=<?php echo $row["vid"];?>">
<!-- 视频标题-->
<?php echo $row["videoname"];?>
</a>
</p>
</li>
<?php } ?>
</ul>
</div>
</div>
<!--/.sidebar-offcanvas-->
</div>
<!--/row-->
</div>
<!--/.container-->
<?php
require_once('tpl/foot.php');
?>