PHP头条
热点:

PHP怎么按日期查询


PHP如何按日期查询
MYSQL里字段addtime为时间戳
我现在须要这样查询
xx.php?u=20130328&page=1 &page=这个用来分页
 这样查询20130328或20130329这一天数据



include "../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);
?>



 
'> 
'>
'>



'>



}
?>     
$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();
?>

------解决方案--------------------
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."");

www.phpzy.comtrue/phprm/19320.htmlTechArticlePHP怎么按日期查询 PHP如何按日期查询 MYSQL里字段addtime为时间戳 我现在须要这样查询 xx.php?u=20130328nbsp;nbsp;这样查询20130328或20130329这一天数据 include"../include/song.inc.php"; $key=$_GET['u']; if(...

相关文章

PHP之友评论

今天推荐