I have a list of employees with birthdate as one of the fields. This field comes from the database as a string, i.e. 19721003 for 10/03/1972. The initial query pulls all employees. I then have the code working to pull just employees for a specific month. I do this by pulling out the month from the string as I loop through the array of all employees. Then echo out the employee if the month matches. What I want to do in addition is sort the results by day of the month ascending. The problem is that I don't know how to sort a second time after I went through the first array.
Seems like somehow load the results into a second array but also add the $bday_day to the results and then sort the second array by the $bday_day field added, then echo out the second array. If so, I'm not sure how to write that syntax.
Am I way off base here or is there an easier way to go about this. If more information is needed I can provide. Thanks
Code:
<?
if ($to_ret > 0)
for ($i=1; $i < $to_ret + 1; $i++)
{
$record_row = odbc_fetch_row($result_A,$i);
$lastname = odbc_result ($result_A,'lastname');
$firstname = odbc_result ($result_A,'altaddr1');
$location = odbc_result ($result_A,'altaddr2');
$phone = odbc_result ($result_A,'altaddr4');
$bday_mth = odbc_result ($result_A,'birthdate');
$bday_mth = preg_replace('/(\d{4})(\d{2})(\d{2})/', '$2', $bday_mth);
$bday_day = odbc_result ($result_A,'birthdate');
$bday_day = preg_replace('/(\d{4})(\d{2})(\d{2})/', '$3', $bday_day);
$email = odbc_result ($result_A,'altcntry');
if ($bday_mth == $whatMonth) {
?>
echo out employee data here...
Am I way off base here or is there an easier way to go about this. If more information is needed I can provide. Thanks