thefollower Posted December 25, 2007 Share Posted December 25, 2007 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] Quote Link to comment https://forums.phpfreaks.com/topic/83088-query-still-not-working/ 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.