精做高難度防水抓漏/壁癌/油漆等工程
責任施工、合約保固!
招牌專業鋁門窗、鍛造門設計及安裝
價格便宜、品質好、設計佳,值得您信賴

首頁  •  j2h 論壇 • 程式設計討論     • 

[php] mysql 怎麼 select 出當月資料

房東:阿傅
發表時間:2010-11-06


php 怎麼 select 出date 當月資料

select * from $table where date=''
例如我只要select 出10月份所以資料
要怎麼寫?






  • 贊助網站       

    廣利不動產-板橋在地生根最實在--新板特區指名度最高、值得您信賴的好房仲
    完整房訊,房屋、店面熱門精選物件,廣利不動產 優質仲介,房屋租賃、買賣資訊透明,交易真安心!
    廣利不動產-新板特區指名度最高、值得您信賴的好房仲
    您的托付,廣利用心為您服務

  • 1 樓住戶:小乖
    發表時間:2010-11-06

    試試 FROM_UNIXTIME 

    例 十月

    SELECT * FROM $table WHERE FROM_UNIXTIME(date, '%c') = 10

    例 2010年十月

    SELECT * FROM $table WHERE FROM_UNIXTIME(date, '%Y-%c') = '2010-10'

    2 樓住戶:小強
    發表時間:2010-11-09

    if (function_exists('date_default_timezone_set')) {
    date_default_timezone_set('Asia/Chongqing');
    }
    $date = isset($_GET['date']) ? $_GET['date'] : date('Y-m-d');
    $date = getdate(strtotime($date));
    $end = getdate(mktime(0, 0, 0, $date['mon'] + 1, 1, $date['year']) - 1);
    $start = getdate(mktime(0, 0, 0, $date['mon'], 1, $date['year']));
    $pre = date('Y-m-d', $start[0] - 1);
    $next = date('Y-m-d', $end[0] + 86400);
    $html = '<table border="1">';
    $html .= '<tr>';
    $html .= '<td><a href="' . $PHP_SELF . '?date=' . $pre . '">-</a></td>';
    $html .= '<td colspan="5">' . $date['year'] . ';' . $date['month'] . '</td>';
    $html .= '<td><a href="' . $PHP_SELF . '?date=' . $next . '">+</a></td>';
    $html .= '</tr>';
    $arr_tpl = array(0 => '', 1 => '', 2 => '', 3 => '', 4 => '', 5 => '', 6 => '');
    $date_arr = array();
    $j = 0;
    for ($i = 0; $i < $end['mday']; $i++) {
    if (!isset($date_arr[$j])) {
    $date_arr[$j] = $arr_tpl;
    }
    $date_arr[$j][($i+$start['wday'])%7] = $i+1;
    if ($date_arr[$j][6]) {
    $j++;
    }
    }
    foreach ($date_arr as $value) {
    $html .= '<tr>';
    foreach ($value as $v) {
    if ($v) {
    if ($v == $date['mday']) {
    $html .= '<td><b>' . $v . '</b></td>';
    } else {
    $html .= '<td>' . $v . '</td>';
    }
    } else {
    $html .= '<td>&nbsp;</td>';
    }
    }
    $html .= '</tr>';
    }
    $html .= '</table>';
    echo $html;




    3 樓住戶:阿偉
    發表時間:2010-11-10

    <?
    if(isset($prm) and $prm > 0){
    $m=$prm+$chm;}else{
    $m= date("m");}

    $d= date("d"); // Finds today's date
    $y= date("Y"); // Finds today's year

    $no_of_days = date('t',mktime(0,0,0,$m,1,$y)); // This is to calculate number of days in a month

    $mn=date('M',mktime(0,0,0,$m,1,$y)); // Month is calculated to display at the top of the calendar

    $yn=date('Y',mktime(0,0,0,$m,1,$y)); // Year is calculated to display at the top of the calendar

    $j= date('w',mktime(0,0,0,$m,1,$y)); // This will calculate the week day of the first day of the month

    for($k=1; $k<=$j; $k++){ // Adjustment of date starting
    $adj .="<td>&nbsp;</td>";
    }

    /// Starting of top line showing name of the days of the week

    echo " <table border='1' bordercolor='#FFFF00' cellspacing='0' cellpadding='0' align=center>

    <tr><td>";

    echo "<table cellspacing='0' cellpadding='0' align=center width='100' border='1'><td align=center bgcolor='#ffff00'><font size='3' face='Tahoma'> <a href='php_calendar.php?prm=$m&chm=-1'><</a> </td><td colspan=5 align=center bgcolor='#ffff00'><font size='3' face='Tahoma'>$mn $yn </td><td align=center bgcolor='#ffff00'><font size='3' face='Tahoma'> <a href='php_calendar.php?prm=$m&chm=1'>></a> </td></tr><tr>";

    echo "<td><font size='3' face='Tahoma'><b>Sun</b></font></td><td><font size='3' face='Tahoma'><b>Mon</b></font></td><td><font size='3' face='Tahoma'><b>Tue</b></font></td><td><font size='3' face='Tahoma'><b>Wed</b></font></td><td><font size='3' face='Tahoma'><b>Thu</b></font></td><td><font size='3' face='Tahoma'><b>Fri</b></font></td><td><font size='3' face='Tahoma'><b>Sat</b></font></td></tr><tr>";

    ////// End of the top line showing name of the days of the week//////////

    //////// Starting of the days//////////
    for($i=1;$i<=$no_of_days;$i++){
    echo $adj."<td valign=top><font size='2' face='Tahoma'>$i<br>"; // This will display the date inside the calendar cell
    echo " </font></td>";
    $adj='';
    $j ++;
    if($j==7){echo "</tr><tr>";
    $j=0;}

    }

    echo "<tr><td colspan=7 align=center><font face='Verdana' size='2'></font></td></tr>";
    echo "</tr></table></td></tr></table>";
    echo "<center><font face='Verdana' size='2'></center></font>";

    ?>





     共 3 人回應  選擇頁數 【第1 頁】 

    姓名:
    佈告內容:
    其他選項: