gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 04:28:51 25 4
gpt4 key购买 nike

我想从表中选择 arrival_date 小于当前日期的记录(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()

关于mysql - 使用 mysql 查询选择小于当前日期的记录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6197263/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com