php时间戳获取全年记录 从option中 获取到某年的值2011~2020mysql是时间戳格式,请问 怎么截取值中的全年时间戳? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我知道用strtotime()转换成时间戳但是 我的sql语句怎么写啊??这个转换的只是一个时间戳,但是 我想获得的是一整年。。? 是要查询 option选择要查询哪年的选择后 会给后台一个值比如是2011到后台后 strtotime()可以把2011选换成时间戳但是 怎么从数据库里面读出2011年所有记录?就是从2011年初到年末的所有值数据库里面 也是时间戳格式 时间戳直接比较select xxxx from xxxx where xxx <endtime and xxx >startime. select * from tbl_name where FROM_UNIXTIME(字段,'%Y')='$year' 前台<form action="1.php" method="post"><select name="radio"> <option value="all">全部时间</option> <?php for($i=2011;$i<=2030;$i++) { ?> <option value="<?=$i?>"><?=$i?></option> <?php } ?></select><input type="submit" value="提交" /></form>后台<?php$radion=$_POST["radio"];if($radion=="all"){ echo "全部时间";}else{ $timeall=strtotime($radion); echo $timeall; $where_string="select * from tbs_index_affiche where FROM_UNIXTIME(addDateTime,'%Y')='$timeall'";}?>mysql的时间戳存在addDateTime中不是很了解FORM_UNIXTIME语句,这个语句显示不出来啊。。 $begintimeall=$radio."-01-01";$endtimeall=$radio."-12-31";strtotime($begintimeall);strtotime($endtimeall);"where name between 起始时间 and 结束时间; select * from tbl_name where 字段 like '$year%' 时间戳,不是时间格式,所以like '$year'是行不通的。推荐版主的from_unixtime()这种方法。 php为什么在本地测试远程采集类。。? Php session 原理 - 用数据库保存session 页面加了<script langage……后就白屏了 北京PHPer求职~2年半开发经验 php怎样定义二维数组? 听说 Turck MMCache 停止开发了? 求助!!!大家都帮我侃侃 php是否可以读取ASP写的COOKIE,如何读?急,请大家帮帮我! 初学php,一些问题请教! PHP中form参数传递的问题(急) 用其他帐号(比如QQ msn)登录自己的网站,需要怎么做呀?? 请问哪个免费的 第三方网站访问量统计,比较好,并且有总访问量的数字显示?
但是 我的sql语句怎么写啊??
这个转换的只是一个时间戳,但是 我想获得的是一整年。。?
选择后 会给后台一个值
比如是2011
到后台后 strtotime()可以把2011选换成时间戳
但是 怎么从数据库里面读出2011年所有记录?就是从2011年初到年末的所有值
数据库里面 也是时间戳格式
时间戳直接比较select xxxx from xxxx where xxx <endtime and xxx >startime.
<select name="radio">
<option value="all">全部时间</option>
<?php
for($i=2011;$i<=2030;$i++)
{
?>
<option value="<?=$i?>"><?=$i?></option>
<?php
}
?>
</select>
<input type="submit" value="提交" />
</form>
后台<?php
$radion=$_POST["radio"];
if($radion=="all")
{
echo "全部时间";
}
else
{
$timeall=strtotime($radion);
echo $timeall;
$where_string="select * from tbs_index_affiche where FROM_UNIXTIME(addDateTime,'%Y')='$timeall'";
}
?>
mysql的时间戳存在addDateTime中
不是很了解FORM_UNIXTIME语句,这个语句显示不出来啊。。
$begintimeall=$radio."-01-01";
$endtimeall=$radio."-12-31";strtotime($begintimeall);
strtotime($endtimeall);
"where name between 起始时间 and 结束时间;
推荐版主的from_unixtime()这种方法。