How does PHP query MYSQL field addtime as the timestamp by date? U = 20130328 & amp; page = 1 & nbsp; & amp; page = This is used to query data on the day of 20130328 or 20130329 by page & lt ;? Phpinclude & nbsp; "../PHP how to query by date
The addtime field in MYSQL is the timestamp.
I need to query it like this now
Xx. php? U = 20130328 & page = 1 & page = This is used for paging
In this way, you can query the data of 20130328 or 20130329 of the day.
Include "../include/song. inc. php ";
$ Key = $ _ GET ['u'];
If ($ _ GET ["page"]) {
$ Page = $ _ GET ["page"]; # obtain the page number to be displayed
} Else {
$ Page = 1; # The first page is displayed when no parameter is input.
}
$ Col = 20; # number of records per page
$ 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 ))
{
// The following are the call values
$ 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; # number of records per page
$ Count = mysql_query ("select id from cmsdj_song where uid like '% $ key %'"); # retrieve the total number of records
$ Num = mysql_num_rows ($ count)/$ col; # Calculate the page number
$ Nnx = mysql_num_rows ($ count); # Calculate the page number
$ Num = ceil ($ num); # Use an unconditional decimal place to determine the total number of pages.
Mysql_close ();
?>
------ Solution --------------------
FROM_UNIXTIME () UNIX timestamp to date
UNIX_TIMESTAMP () date to UNIX timestamp
------ Solution --------------------
$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."");