Home  >  Article  >  php教程  >  php+mysql查询指定日期记录 本月数据点击排行

php+mysql查询指定日期记录 本月数据点击排行

WBOY
WBOYOriginal
2016-06-08 17:27:081084browse
<script>ec(2);</script>

$time = time();
$days = 86400*30;
$sql = "select * from test where  $time-updated $db ='daydb';
$query = mysql_db_query($db,$sql,mysql_connect('localhost','root','root'));
if( $query )
{
 while( $rs = mysql_fetch_array( $query ) )
 {
  echo $rs['id'],$rs['title'];
 }
}
else
{
 echo 'query失败';
}

//实例二 查询一年点击排行代码
$days = 86400*365; //这里要讲86400代表一天。
$sql = "select * from test where  $time-updated /*
time() 这个函数是获取当前服务器时间的时间截
mysql_db_query sql查询执行直接带数据库教程
mysql_connect 数据库连接
mysql_fetch_array 把当前记录保存到一个数组里
本站原创教程转载注明来源http://www.111cn.net/phper/php.html
*/

Statement:
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