Jump to content

Union Issue


Lone_Ranger
Go to solution Solved by Barand,

Recommended Posts

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?

 

 

Link to comment
Share on other sites

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";
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.