While loop issue[solved]

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Snobbery08
Forum Newbie
Posts: 13
Joined: Sun Jan 06, 2008 10:45 am

While loop issue[solved]

Post by Snobbery08 »

My while loop is echo'in incorrectly but i am not sure if i have my query wrong or my while loop. It should not echo anything as the record id is found on the other table yet it still echo's the information :S


Code: Select all

 
<?php
$GetAppeals = mysql_query("SELECT * FROM reportedusers, reportsituation WHERE reportedusers.RecordID <> reportsituation.RecordID")
  or die (mysql_error());  
 
while($row = mysql_fetch_array($GetAppeals)) {
$RecordID = $row['RecordID'];
$ReportedPlayer = $row['ReportedPlayer'];
$Reason = $row['Reason'];
$FrozenBy = $row['FrozenBy'];
 
//Get reported Player's name
$GetUsername = mysql_query("SELECT Username FROM userregistration WHERE UserID='$ReportedPlayer'")
    Or die(mysql_error());
$GetUsernameRow = mysql_fetch_assoc($GetUsername);
$Username = $GetUsernameRow['Username'];
If($Username == ''){
$Username = '--Deleted User--';
}
 
//Get Frozen By name
$GetUsername2 = mysql_query("SELECT Username FROM userregistration WHERE UserID='$FrozenBy'")
    Or die(mysql_error());
$GetUsername2 = mysql_fetch_assoc($GetUsername2);
$Username2 = $GetUsername2['Username'];
?>
    <tr>
    <td width="100" align="center"><span class="NegativeMoney"><?=$Username?>[<?=$ReportedPlayer?>]</span></td>
    <td width="100" align="center"><?=$Reason?></td>
    <td width="100" align="center"><span class="PositiveMoney"><?=$Username2?>[<?=$FrozenBy?>]</span></td>
    <td width="100" align="center"><span class="PositiveMoney">Awaiting staff response!</span></td>
    <td width="100" align="center"><a href="frozenaccont2.php?RecordID=<?=$RecordID?>">View Appeal</a></td>
    </tr>
<?php
        }
?>
Last edited by Snobbery08 on Mon Jan 14, 2008 2:37 pm, edited 1 time in total.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: While loop issue

Post by pickle »

The only IF condition you have is the one that overwrites a blank username - nothing that decides if anything is output or not.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Snobbery08
Forum Newbie
Posts: 13
Joined: Sun Jan 06, 2008 10:45 am

Re: While loop issue

Post by Snobbery08 »

Yeah i think its an issue with my query. I will post a topic in the mysql section to see what they can come up with.

Thankyou.
Post Reply