使用mysql查询来选择小于当前日期的记录?

问题描述

| 我想从表中选择到达日期小于当前日期(arrival_date是表honymoon_enquries表中的字段名称)的记录,我的代码
<?PHP
error_reporting(E_ALL ^ E_NOTICE);
    session_start();

    require_once(\"config.PHP\");

    if($_SESSION[\"valid\"] != true) 
    {   
        header(\"Location: index.PHP\");

        exit(0);    
    }   

    if(count($_REQUEST[\'users\']) > 0)   
    {
        //print_r($_REQUEST[\'users\']);     
        $DeleteList = implode(\",\",$_REQUEST[\'users\']);

        $UpdateQuery = \" UPDATE honymoon_enquries SET deleted = \'1\' WHERE id IN (\".$DeleteList.\") \";

        MysqL_query($UpdateQuery);    
    }

    if(isset($_REQUEST[\'pageid\']) && $_REQUEST[\'pageid\'] > 1)    
    {    
        $start = ($_REQUEST[\'pageid\'] - 1) * 10;

        $pageidprev = $_REQUEST[\'pageid\'] - 1;

        $pageidnext = $_REQUEST[\'pageid\'] + 1;    
    }    
    else  
    {    
        $start = 0;

        $pageidprev = 1;

        $pageidnext = 2;   
    }

    $countquery = \"SELECT count(*) AS counter FROM honymoon_enquries WHERE status=\'1\' AND deleted = \'0\' \";


    $countres=MysqL_query($countquery);

$count = MysqL_fetch_array($countres);

    //print_r($count);

     $query = \"select * from honymoon_enquries WHERE status=\'1\' AND deleted = \'0\' order by arrival_date DESC LIMIT \".$start.\",10 \";  // i want update this query

$res=MysqL_query($query);

if(MysqL_num_rows($res) < 10)    
{   
        $pageidnext = $pageidnext-1;    
}    

if(($start+10) > $count[\'counter\'])   
{  
    $end = $count[\'counter\']; 
}  
else   
{ 
    $end = $start+10;   
}

$main .= \"  
            <script>



            function DeleteUser()
            {
                if(confirm(\'Are you sure want to delete this contact?\'))
                {
                    document.frm.submit();
                }
            }

            </script>

            <div class=heading>Manage Subscribers</div>

            $msg

            <form name=\'frm\' method=\'post\' action=\'users.PHP\'>

            <table width=100%>

            <tr>

            <td colspan=\'6\'><strong>Showing \".($start+1).\" to \".$end.\" of \".$count[\'counter\'].\"</strong></td>

            </tr>

            <tr>

            <td colspan=\'6\' align=\'left\'>

            <a href=\'users.PHP?pageid=\".$pageidprev.\"\'>Prev</a>&nbsp;

            <a href=\'users.PHP?pageid=\".$pageidnext.\"\'>Next</a>

            </td>

            </tr>

            <tr>

            <td><strong>Check</strong></td>

            <td><strong>Name</strong></td>

            <td><strong>Email</strong></td>

            <td><strong>Phone</strong></td>

            <td><strong>Arival Date</strong></td>

            <td><strong>Action</strong></td>

            </tr>

            \";



            while ($resresult=MysqL_fetch_array($res))

        {
            //print_r($resresult);

            $main .= \"

            <tr>

            <td><input type=\'checkBox\' name=\'users[]\' value=\'\".$resresult[\'id\'].\"\' ></td>

            <td align=\'left\'>\".$resresult[\'client_name\'].\"</td>

            <td align=\'left\' >\".$resresult[\'client_email\'].\"</td>

            <td align=\'left\' >\".$resresult[\'client_phone\'].\"</td>

            <td align=\'center\' >\".$resresult[\'arrival_date\'].\"</td>

            <td align=\'center\' ><a href=\'viewuser.PHP?pageid=\".$resresult[\'id\'].\"\'>View User</a></td>

            </tr>

             \";
        }

        $main .= \"<tr>

            <td colspan=\'6\' align=\'left\'>

            <a href=\'javascript:void(0);\' onclick=\'DeleteUser();\'>Delete</a>&nbsp;

            </td>

            </tr>\";

            $main .= \"

            </table>

            </form>

             \";

    $yescallme=1;

    $page = \"users\";

    require_once(\"includes/template.PHP\");
    ?>
谢谢。     

解决方法

        尝试这个:
SELECT * FROM honymoon_enquries
WHERE arrival_date < NOW()
    

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...