Jump to content

[SOLVED] mysql ordering by last 30 days


atticus

Recommended Posts

noob question I know  ??? How do I order the following search to return only records processed in the last 30 days?

 

<?php
echo "<h3>Subjects Searched in Last Thirty Days:</h3><center>
<table border=1 style=\"border-collapse:collapse;\">
<tr>
	<th style=\"padding-right:5px;\">Last Name, First Name</th>
	<th style=\"padding-right:5px;text-align:center;\">Processed (yyyy - mo - dy)</th>
</tr>
";
$sql = "SELECT * FROM `order` WHERE cust_id = $id AND processed = 'yes' ORDER BY processeddate DESC, last_name ASC"; 
   $query = mysql_query($sql) or die('Error, query failed : ' . mysql_error());
while($row = mysql_fetch_array($query)) {
echo "<tr>
	<td>".$row['last_name'].", ".$row['first_name']."</td> ";
echo    "<td style=\"text-align:center;\">".$row['processeddate']."</td>
</tr>";		
}	  echo "</table></center>";	  
?>

Link to comment
https://forums.phpfreaks.com/topic/85254-solved-mysql-ordering-by-last-30-days/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.