The following snippet populates a dropdown with a date/company. I must populate the dropdown from two different tables(databases). This is working fine but going by date, all the records from one company appear at the top, then the dates start again with the second company at the bottom of the dropdown. I wanted to see if I could sort the dropdown by date once the dropdown is loaded from both results(companies) by date.
Thanks for any suggestions.
if ($s_count > 0 And $t_count > 0)
{
echo "<select name='perend'>\n";
while ($rows = odbc_fetch_row($s_result11)) {
$perend = odbc_result ($s_result11,'transdate');
$company = odbc_result ($s_result11,'audtorg');
$pattern = "/(\d{4})(\d{2})(\d{2})/";
$mod_s_date = preg_replace($pattern,"$2/$3/$1",$perend);
$out = $mod_s_date . ' ' . $company;
echo '<option value="'.$out.'">'.$out.'</option>'."\n";
}
while ($rows = odbc_fetch_row($t_result11)) {
$perend = odbc_result ($t_result11,'transdate');
$company = odbc_result ($t_result11,'audtorg');
$pattern = "/(\d{4})(\d{2})(\d{2})/";
$mod_s_date = preg_replace($pattern,"$2/$3/$1",$perend);
$out = $mod_s_date . ' ' . $company;
echo '<option value="'.$out.'">'.$out.'</option>'."\n";
}
echo "</select>\n";
}
Thanks for any suggestions.
if ($s_count > 0 And $t_count > 0)
{
echo "<select name='perend'>\n";
while ($rows = odbc_fetch_row($s_result11)) {
$perend = odbc_result ($s_result11,'transdate');
$company = odbc_result ($s_result11,'audtorg');
$pattern = "/(\d{4})(\d{2})(\d{2})/";
$mod_s_date = preg_replace($pattern,"$2/$3/$1",$perend);
$out = $mod_s_date . ' ' . $company;
echo '<option value="'.$out.'">'.$out.'</option>'."\n";
}
while ($rows = odbc_fetch_row($t_result11)) {
$perend = odbc_result ($t_result11,'transdate');
$company = odbc_result ($t_result11,'audtorg');
$pattern = "/(\d{4})(\d{2})(\d{2})/";
$mod_s_date = preg_replace($pattern,"$2/$3/$1",$perend);
$out = $mod_s_date . ' ' . $company;
echo '<option value="'.$out.'">'.$out.'</option>'."\n";
}
echo "</select>\n";
}