I need to amend some existing code to search a table based upon the number of entries for that month and return a value e.g 300 jobs have been posted this month.
At the moment I am just returning the last date from the table, however I need to now look at this date and then create a variable and create a SQL statement to search inbetween the months.
Any ideas on how to best approach this?
The code I am using at the moment:
// Connect To MySQL Server
@mysql_connect($server, $username, $password) or die("Couldn't Connect to Database");
// Select Database
@mysql_select_db($database) or die("Couldn't Select Database");
$sql = "SELECT *, UNIX_TIMESTAMP(date) AS udate FROM job";
// Execute SQL and exit if failure
$sql_result = mysql_query($sql) or die('SQL Error');
$num_rows = mysql_num_rows($sql_result);
if ($num_rows == 0){
echo '<span class=general>Sorry your details did not match any of our records. Please return to the search page <a href=../login.php>here</a></span>';
exit;
}
while ($row = mysql_fetch_array($sql_result)){
$date = $row["udate"];
}
// Format & Print date
echo date("d/m/Y",$date);
}