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
https://forums.phpfreaks.com/topic/85953-my-while-looploops-too-many-times/
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
	}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.