Jump to content

Recommended Posts

I have a while loop for mysql_num_rows but its going on for infinite im sure its a trivial mistake but i been working all day today and i cannot see where i have gone wrong.. this is what i got see if you can spot it :

 

 

include("include.php");
$Getweapons = mysql_query("SELECT * FROM userweapons
                    WHERE UserID='{$_SESSION['Current_User']}'")
			or die(mysql_error());

<?
If(mysql_num_rows($Getweapons) < 1){
?>
<div id="bv_" style="position:absolute;left:370px;top:400px;width:250px;height:24px;z-index:11" align="center">
<font style="font-size:15px" color="#FFFFFF" face="Arial"><i>You do not own any weapons!</i></font></div>
<?
}Else{
?>

<div id="bv_" style="position:absolute;left:30px;top:350px;width:150px;height:22px;z-index:1" align="center">
<table width="1000" border="1" cellpadding="0" cellspacing="0">
<tr>
    <td width="200"><font style="font-size:14px" color="#FFFFFF" face="Arial"><center><b><u>Weapon Name:</center></b></u></font></td>
    <td width="200"><font style="font-size:14px" color="#FFFFFF" face="Arial"><center><b><u>Equipped?:</center></b></u></font></td>
<td width="200"><font style="font-size:14px" color="#FFFFFF" face="Arial"><center><b><u>Type:</center></b></u></font></td>
  </tr>
<?
While($Weaponrow = mysql_num_rows($Getweapons)){
$WeaponID = $Weaponrow['WeaponID'];
$WeaponQuantity = $Weaponrow['Quantity'];
$Equipped = $Weaponrow['Equipped'];

If($Equipped == '1'){
$Equipped = 'Yes';
}Else{
$Equipped = 'No';
}

$GetWeaponName = mysql_query("SELECT * FROM weapons WHERE WeaponID='$WeaponID'")
or die(mysql_error());
$WeaponNameRow = mysql_fetch_assoc($GetWeaponName);
$WeaponName = $WeaponNameRow['Name'];
$WeaponType = $WeaponNameRow['Type'];
?>
  <tr>
    <td width="200"><center><font style="font-size:14px" color="#32CD32" face="Arial"><?=$WeaponName?></a></center></font></td>
    <td width="100"><center><font style="font-size:14px" color="#32CD32" face="Arial"><?=$Equipped?></center></font></td>
<td width="200"><center><font style="font-size:14px" color="#32CD32" face="Arial"><?=$WeaponType?></center></font></td>
  
  </tr>
<?
  }
?>
</table>
<?
}

Link to comment
https://forums.phpfreaks.com/topic/79889-solved-while-loop-never-ends/
Share on other sites

not a good idea to execute queries within a loop - many hosts limit the number of queries per page...

 

 

what output are you getting? do you get a script time out error?

 

what resutls are returned just running the initial query in phpmyadmin?

 

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.