Jump to content

Query still not working


thefollower

Recommended Posts

Ok sorry about this the query half works it loads the correct row but the while loop echo's the wrong fields in the wrong place which is weird i will apply a print screen of my database table to show you that the spelling is correct so im not sure whats causing this:

 

Query with while loop:

<?php
$GetMessages = mysql_query("SELECT * FROM messages WHERE (Sender='$ReportedPlayer' AND Receiver='$OtherPlayer') OR (Sender='$OtherPlayer' AND Receiver='$ReportedPlayer')
UNION
SELECT * FROM textmessages WHERE (Sender='$ReportedPlayer' AND Receiver='$OtherPlayer') OR (Sender='$OtherPlayer' AND Receiver='$ReportedPlayer')
UNION
SELECT * FROM phonecalls WHERE (Sender='$ReportedPlayer' AND Receiver='$OtherPlayer') OR (Sender='$OtherPlayer' AND Receiver='$ReportedPlayer')
ORDER BY SentTime ASC")
or die(mysql_error());
?>

 

 

Table:

<table width="600" border="1" cellpadding="0" cellspacing="0">
		<tr>
			<td width="200"><font style="font-size:14px" color="#FFFFFF" face="Arial"><center><b><u>Sender:</center></b></u></font></td>
			<td width="200"><font style="font-size:14px" color="#FFFFFF" face="Arial"><center><b><u>Reciever:</center></b></u></font></td>
			<td width="200"><font style="font-size:14px" color="#FFFFFF" face="Arial"><center><b><u>Message:</center></b></u></font></td>
			<td width="200"><font style="font-size:14px" color="#FFFFFF" face="Arial"><center><b><u>Sent On:</center></b></u></font></td>

	</tr>

<?php
while($rowmessage = mysql_fetch_assoc($GetMessages)){
	$SenderID = $rowmessage['Sender'];
	$RecieverID = $rowmessage['Receiver'];
	$Message = $rowmessage['MessageText'];
	$SentTime = $rowmessage['SentTime'];

	If($SenderID == $ReportedPlayer){
		$Font = '#32CD32';
		}Else{
		$Font = '#FFFFFF';
		}
	If($RecieverID == $ReportedPlayer){
		$Font2 = '#32CD32';
		}Else{
		$Font2 = '#FFFFFF';
		}

	$GetUserName = mysql_query("SELECT Username FROM userregistration WHERE UserID ='$SenderID'")
	or die(mysql_error());
	$GetUserNameRow = mysql_fetch_assoc($GetUserName);
	$Sender = $GetUserNameRow['Username'];

	$GetUserName2 = mysql_query("SELECT Username FROM userregistration WHERE UserID ='$RecieverID'")
	or die(mysql_error());
	$GetUserNameRow2 = mysql_fetch_assoc($GetUserName2);
	$Reciever = $GetUserNameRow2['Username'];

	If($Reciever == ''){
	$Reciever = '----Deleted User----';
	}
	If($Sender == ''){
	$Sender = '----Deleted User----';
	}
	?>
		<tr>
	<td width="100"><center><font style="font-size:14px" color="<?=$Font?>" face="Arial"><?=$Sender?>[<?=$SenderID?>]</center></font></td>
	<td width="100"><center><font style="font-size:14px" color="<?=$Font2?>" face="Arial"><?=$Reciever?>[<?=$RecieverID?>]</center></font></td>
	<td width="100"><center><font style="font-size:14px" color="#FFFFFF" face="Arial"><?=$Message?></center></font></td>
	<td width="100"><center><font style="font-size:14px" color="#FFFFFF" face="Arial"><?=$SentTime?></center></font></td>

		</tr>
</td>

<?
}
?>
</div>

 

 

Picture explains this better than i could.

Hope you can help.

 

[attachment deleted by admin]

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.