timmah1 Posted July 13, 2008 Share Posted July 13, 2008 I have 2 different databases, one named 'messages' and one named 'attack_log' both databases have the same fields in them If there is a message to somebody in either of the database with a status of 0, i need an icon to blink, and if there is no message or status of 1, i need a different icon to show the problem is, no matter how i do this, it either shows a regular icon and a blinking icon, or none at all. can anybody help me out with this? $new3 = "(SELECT * FROM messages WHERE message_to = '" .$_SESSION['SESS_USERNAME']. "') UNION ALL (SELECT * FROM attack_log WHERE message_to = '" .$_SESSION['SESS_USERNAME']. "')"; $result3 = mysql_query($new3); $numberall = mysql_num_rows($result3); if($numberall == 0){ echo "<a href='messages.php'><img src='img/mail.png' height='25' title='check your mail and attack logs' alt='check your mail and attack logs' border='0' /></a>"; } $row3 = mysql_fetch_array($result3); if($row3['status'] == 0){ echo "<a href='messages.php'><img src='img/mail.gif' height='25' title='check your mail and attack logs' alt='check your mail and attack logs' border='0' /></a>"; } else { echo "<a href='messages.php'><img src='img/mail.png' height='25' title='check your mail and attack logs' alt='check your mail and attack logs' border='0' /></a>"; } thanks in advance Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted July 13, 2008 Share Posted July 13, 2008 If you want to UNION your queries, you'll need to have each query return a count (which is more efficient anyway): $sql = "(SELECT COUNT(*) FROM messages WHERE message_to='".$_SESSION['SESS_USERNAME']."') UNION ALL (SELECT COUNT(*) FROM attack_log WHERE message_to='".$_SESSION['SESS_USERNAME']."')" $result = mysql_query($sql) or trigger_error(mysql_error(),E_USER_ERROR); $count1 = mysql_result($result,0); $count2 = mysql_result($result,1); if($count1 == 0 && $count2 == 0){ //no rows in either }else{ //rows in one or the other } Of course, i would question your database structure if you have two tables with the same fields in them... Quote Link to comment Share on other sites More sharing options...
timmah1 Posted July 13, 2008 Author Share Posted July 13, 2008 thank you works perfect now Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.