Hi all,
I have the following UNION statement:
<?
$query_messages_today = mysql_query("(SELECT pm_message_title AS title, date_format(pm_message_date, '%D %b %T') AS date FROM pm_messages) UNION ALL (SELECT pm_milestone_title AS title, date_format(pm_milestone_subdate, '%D %b %T') AS date FROM pm_milestones ORDER BY date)");
$total_messages = mysql_num_rows($query_messages_today);
if ($total_messages > 0){
?>
<TABLE width="100%" cellpadding="0" cellspacing="0">
<TBODY>
<TR>
<TD>
<?
$alternate = 2;
while ($row = mysql_fetch_array($query_messages_today)) {
if ($alternate == "1") {
$color = "#ffffff";
$alternate = "2";
} else {
$color = "#E5E5E5";
$alternate = "1";
}
?>
<TABLE width="100%" bgcolor="<? echo $color ?>">
<TBODY>
<TR>
<TD width="50"><div align="center"><img src="images/comment_img.gif" width="39" height="9"></div></TD>
<TD>
<b><a class="black" href="#"><? echo $row['title'] ?></a></b><br>
<span class="outputBlackSmlX">by McAleer in Assets, <? echo $row['date'] ?></span></TD>
</TR>
</TBODY>
</TABLE>
</TD>
</TR>
<TR>
<TD>
<?
}
?>
</TD>
</TR>
</TBODY>
</TABLE>
<?
} else {
?>
<span class="outputBlack">No activity today</span>
<?
}
?>
It outputs the correct results except the values are not ordered correctly.
Can anyone see where i might be going wrong?
Cheers,
macca