Lone_Ranger Posted December 21, 2013 Share Posted December 21, 2013 if ($countnot[0] == "0") { echo "<p align=center><font size=2>You Currently Have No New Notifications</font></p>"; } else { $union=mysql_query("SELECT date, message, address from notifications where nuser='$row[id]' UNION SELECT date, message, address from blogsnotification where user='$joysong=[friendid]' UNION SELECT date, message, address from inmymind where user='$joysong=[friendid]' UNION SELECT date, message, address from friendsnotification where accountid='$row[id]' ORDER by date DESC LIMIT 0,15") or trigger_error(mysql_error()); $notes = mysql_fetch_array($union); echo "<table border=0 width=100% cellspacing=0 cellpadding=0> <tr> <td> <table border=0 width=100% cellspacing=0 cellpadding=0> <tr> <td width=141><p align=right><b>$notes[date]</b></p></td> <td width=14> </td> <td><p align=center><a href=$notes[address]>$notes[message]</a></p></td> <td width=8 bgcolor=#008000> </td> <td width=43><p align=center></img></p></td> </tr> </table> </td> </tr> <tr> <td background=http://www.sentuamessage.com/divider.jpg> </td> </tr> </table>"; } The union statement made is working but it only shows the latest result. It does not list the 15 results from the 3 tables like I wanted too. Why is this? Quote Link to comment https://forums.phpfreaks.com/topic/284886-union-issue/ Share on other sites More sharing options...
jazzman1 Posted December 21, 2013 Share Posted December 21, 2013 Loop the data! Quote Link to comment https://forums.phpfreaks.com/topic/284886-union-issue/#findComment-1462902 Share on other sites More sharing options...
Lone_Ranger Posted December 21, 2013 Author Share Posted December 21, 2013 still nothing with the loop :/ Quote Link to comment https://forums.phpfreaks.com/topic/284886-union-issue/#findComment-1462905 Share on other sites More sharing options...
Barand Posted December 21, 2013 Share Posted December 21, 2013 post the code Quote Link to comment https://forums.phpfreaks.com/topic/284886-union-issue/#findComment-1462907 Share on other sites More sharing options...
Lone_Ranger Posted December 21, 2013 Author Share Posted December 21, 2013 no actually I haven't got a clue how to loop this Quote Link to comment https://forums.phpfreaks.com/topic/284886-union-issue/#findComment-1462908 Share on other sites More sharing options...
Solution Barand Posted December 21, 2013 Solution Share Posted December 21, 2013 http://www.php.net/manual/en/function.mysql-fetch-array.php Look at the examples Quote Link to comment https://forums.phpfreaks.com/topic/284886-union-issue/#findComment-1462909 Share on other sites More sharing options...
Lone_Ranger Posted December 21, 2013 Author Share Posted December 21, 2013 (edited) sorted im such an idiot, my $notes = mysql_fetch_array($union); { should have been white($notes = mysql_fetch_array($union)) { Edited December 21, 2013 by Lone_Ranger Quote Link to comment https://forums.phpfreaks.com/topic/284886-union-issue/#findComment-1462912 Share on other sites More sharing options...
Barand Posted December 21, 2013 Share Posted December 21, 2013 You might also want to change the two occurences of WHERE user='$joysong=[friendid]' to WHERE user='$joysong[friendid]' Easier to spot when your query is structured instead of being strung out across the office $sql = "SELECT date, message, address FROM notifications WHERE nuser='$row[id]' UNION SELECT date, message, address FROM blogsnotification WHERE user='$joysong=[friendid]' UNION SELECT date, message, address FROM inmymind WHERE user='$joysong=[friendid]' UNION SELECT date, message, address FROM friendsnotification WHERE accountid='$row[id]' ORDER by date DESC LIMIT 0,15"; Quote Link to comment https://forums.phpfreaks.com/topic/284886-union-issue/#findComment-1462915 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.