thefollower Posted December 2, 2007 Share Posted December 2, 2007 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> <? } Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted December 2, 2007 Share Posted December 2, 2007 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? Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted December 2, 2007 Share Posted December 2, 2007 have you looked at using a loop like while($row = mysql_fetch_array($result)){ it goes till no more results are found, and saves you a lot of sql Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted December 2, 2007 Share Posted December 2, 2007 crikey - didn't even see that!!!!! yes use while ($row = mysql_fetch_assoc($Getweapons)) Quote Link to comment Share on other sites More sharing options...
thefollower Posted December 3, 2007 Author Share Posted December 3, 2007 how come u cant use num rows then ? Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted December 3, 2007 Share Posted December 3, 2007 cause its a waste while($row = mysql_fetch_array) will take your query and actually give you all the results looped out. Quote Link to comment 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.