Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用mysql查询选择小于当前日期的记录?_Mysql_Datetime_Date - Fatal编程技术网

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

使用mysql查询选择小于当前日期的记录?,mysql,datetime,date,Mysql,Datetime,Date,我想从表中选择到达日期小于当前日期的记录(到达日期是表Honymon\u Enquiries表中的字段名)我的代码为的日期 <?php error_reporting(E_ALL ^ E_NOTICE); session_start(); require_once("config.php"); if($_SESSION["valid"] != true) { header("Location: index.php");

我想从表中选择到达日期小于当前日期的记录(到达日期是表Honymon\u Enquiries表中的字段名)我的代码为的日期

<?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()
从honymoon\u文件中选择*
到达地点\日期<现在()
试试这个:

SELECT * FROM honymoon_enquries
WHERE arrival_date < NOW()
从honymoon\u文件中选择*
到达地点\日期<现在()

您的PHP代码在这里不是特别有用-更好的是表模式,可能是您尝试查询的结果。您的PHP代码在这里不是特别有用-更好的是表模式,可能是您尝试查询的结果。@shani inlove:这是什么意思?你有什么结果?还是哪个错误?我的问题没问题,相信我。告诉我们更多信息,例如您的表定义、我的查询得到的结果和预期结果。我们将解决您的问题:)致命错误:调用C:\wamp\www\data\newsletter\user2.php中的undefined function NOW(),第88i行我修改了查询,如$query=“选择*来自honymoon\u equiries,其中到达日期@shani inlove:
NOW()
是一个内部MySql函数,因此您必须在查询中使用它:它必须由MySql处理,而不是由PHP处理。看看@shani inlove:这不起作用是什么意思?您有哪个结果?或者哪个错误?我的查询是可以的,相信我。请告诉我们更多信息,例如您的表定义、您在我的查询中得到的结果以及预期结果结果。我们将解决您的问题:)致命错误:调用C:\wamp\www\data\newsletter\user2.php中的undefined function NOW(),第88行我修改了查询,如….$query=“SELECT*FROM honymoon\u enquiries,其中arrival\u date@shani inlove:
NOW()
是一个内部MySql函数,所以您必须在查询中使用它:它必须由MySql处理,而不是由PHP处理。看一看