Jump to content

My while loop.loops too many times


SirChick

Recommended Posts

My while loop is looping almost 4 more times than it should be.. there for it echo's the same rows in my database 4 times rather than just once.. which is a bit strange.

 

This is what i got:

 

<?php
//select recordid from reportedusers where the same recordid is not found in reportsituation table
$GetAppeals = mysql_query("SELECT * FROM reportedusers, reportsituation WHERE reportedusers.RecordID <> reportsituation.RecordID")
  or die (mysql_error()); 
while($row = mysql_fetch_array($GetAppeals)) {
echo 'stuff';
}
?>

 

It should do none for echo's as record Id can be found in the report situation table. Is my query wrong or my while loop ?

Link to comment
Share on other sites

Oh ok here you go : :)

 

While loop:

 

<?php
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
	}
?>

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.