Using mysql query to select record less than current date?
I want to select records from table which arrival_date is less than current date (arrival_date is field name in table honymoon_enquries table) date my code is
<?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>
<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>
</td>
</tr>";
$main .= "
</table>
</form>
";
$yescallme=1;
$page = "users";
require_once("includes/template.php");
?>
Thank you.
Try this:
SELECT * FROM honymoon_enquries
WHERE arrival_date < NOW()
精彩评论