Table of Contents
PHP如何按日期查询
Jun 23, 2016 pm 02:04 PM MYSQL里字段addtime为时间戳
我现在须要这样查询
xx.php?u=20130328&page=1 &page=这个用来分页
这样查询20130328或20130329这一天数据
<?phpinclude "../include/song.inc.php";$key = $_GET['u'];if($_GET["page"]){ $page=$_GET["page"];#获取要显示的页码}else{ $page=1;#没有参数传入时,显示第一页}$col=20;#每页显示记录条数$p=($page-1)*$col;$runSql = mysql_query("select * from cmsdj_song where uid = '$key' order by id desc limit ".$p.",".$col."");while($row = mysql_fetch_array($runSql)){//下面这些是调用值$sid=$row['id'];$suid=$row['uid'];$supip=$row['upip'];$name=$row['name'];$sname=substr($name,0,30);$sfile=$row['file'];$surl=$row['url'];$swjdx=$row['wjdx'];$stime=date('Y-m-d H:i:s',$row['addtime']);//$b64file=base64_encode($surl);?><table width='100%' border='0' cellpadding='0' cellspacing='0' class='tb_style'><tr><center><td width='5%' height='20' class='td_border'> <? echo $sid;?></td><td width='25%' class='td_border'><a href='u.php?i=<? echo $sfile;?>'> <? echo $sname;?></a></td><td width='20%' class='td_border'><a href='u.php?i=<? echo $sfile;?>'><? echo $sfile;?></a></td><td width='20%' class='td_border'><a href='u.php?i=<? echo $sfile;?>'><? echo $surl;?></a></td><td width='5%' class='td_border' align='center'><? echo $swjdx;?></td><td width='10%' class='td_border' align='center'><? echo $supip;?></td><td width='12%' class='td_border' align='center'><? echo $stime;?></td><td width='3%' class='td_border' align='center'><a href='del.php?id=<? echo $sid;?>'><img src='/img/no.gif' border='0' alt="PHP如何按日期查询" ></a></td></tr></center></table><?php}?> <?php$col=20;#每页显示记录条数$count=mysql_query("select id from cmsdj_song where uid like '%$key%'");#取得记录总条数$num = mysql_num_rows($count)/$col;#计算页数$nnx = mysql_num_rows($count);#计算页数$num=ceil($num);#无条件小数进位确定总页数mysql_close();?>
Copy after login
回复讨论(解决方案)
FROM_UNIXTIME() UNIX时间戳转换为日期
UNIX_TIMESTAMP() 日期转换为UNIX时间戳
$u = $_GET['u'];$starttime = strtotime($u.'000000');$endtime = strtotime($u.'235959');$runSql = mysql_query("select * from cmsdj_song where addtime > '$starttime' and addtime<'$endtime' order by id desc limit ".$p.",".$col."");
Copy after login
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot tools Tags

Hot Article
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

11 Best PHP URL Shortener Scripts (Free and Premium)

Working with Flash Session Data in Laravel

Simplified HTTP Response Mocking in Laravel Tests

cURL in PHP: How to Use the PHP cURL Extension in REST APIs

Build a React App With a Laravel Back End: Part 2, React

12 Best PHP Chat Scripts on CodeCanyon
