如何逐月获取记录

时间:2011-04-30 03:05:41

标签: php mysql

下拉月份和年份,然后提交。

<span class="pln">fieldid</span><span class="pun">,</span>
<span class="pln"> name</span>
<span class="pun">,</span>
<span class="pln">&nbsp; &nbsp; &nbsp;time(int)<br></span>
<span class="pun">============================</span><span class="pln"><br></span>
<span class="lit">1</span>
<span class="pln"> &nbsp; &nbsp; &nbsp; &nbsp;test1 &nbsp; &nbsp; </span>
<span class="lit">158565545</span><span class="pln"><br></span><span class="lit">2</span>
<span class="pln"> &nbsp; &nbsp; &nbsp; &nbsp;test2 &nbsp; &nbsp; </span>
<span class="lit">159545222</span><span class="pln"><br></span><span class="lit">3</span>
<span class="pln"> &nbsp; &nbsp; &nbsp; &nbsp;test3 &nbsp; &nbsp; </span>
<span class="lit">159995545</span><span class="pln"><br></span>

fieldid,  name,    time(INT)
============================
1        test1     158565545
2        test2     152548856
3        test3     159544856

等...

显示报告如:     test1是当月     test2适用于prev。月 等等。

当我第一次在当月报告显示时加载页面时,如何每月获取记录?

1 个答案:

答案 0 :(得分:0)

select *
  from MyTable
 where MONTH(FROM_UNIXTIME(time)) = MONTH(NOW())