ScottRiley Posted August 16, 2006 Share Posted August 16, 2006 So, I'm trying to echo all the results of an array I achieved from a query, simple enough:[code] <?php echo"Welcome ".$_SESSION['username']."!<BR>"; echo"You have ".$rows." Business members:<BR>"; while($array=mysql_fetch_array($result)) { echo " ".$array['Username']."<BR>"; } ?>[/code]However, this tells me I have 6 business users, but only echos 5 of them. I checked the database, and I DO have 6 users, so why is it just echoing just 5?Thanks in advanceScott Quote Link to comment Share on other sites More sharing options...
HeyRay2 Posted August 16, 2006 Share Posted August 16, 2006 Post the code that runs your querty, and we'll be on the right track to getting this figured out for you... ;) Quote Link to comment Share on other sites More sharing options...
ScottRiley Posted August 16, 2006 Author Share Posted August 16, 2006 [code]$sql="SELECT * FROM southport_businesses"; $result=mysql_query($sql); $rows=mysql_num_rows($result); $array=mysql_fetch_array($result);code][/code] Quote Link to comment Share on other sites More sharing options...
czambran Posted August 16, 2006 Share Posted August 16, 2006 WHen are u assigning a value to the variable $rows? Are you sure one of the username is not just a blank? Quote Link to comment Share on other sites More sharing options...
bbaker Posted August 16, 2006 Share Posted August 16, 2006 [quote author=ScottRiley link=topic=104502.msg416887#msg416887 date=1155744347][code]$sql="SELECT * FROM southport_businesses"; $result=mysql_query($sql); $rows=mysql_num_rows($result); $array=mysql_fetch_array($result);[/code][/quote]try removing [code]$array=mysql_fetch_array($result);[/code] from this bit, since you're using it in your while statement, thus:[code]<?php$sql="SELECT * FROM southport_businesses";$result=mysql_query($sql);$rows=mysql_num_rows($result);echo"Welcome ".$_SESSION['username']."!<BR>";echo"You have ".$rows." Business members:<BR>";while($array=mysql_fetch_array($result)){ echo " ".$array['Username']."<BR>";}?>[/code] Quote Link to comment Share on other sites More sharing options...
ScottRiley Posted August 17, 2006 Author Share Posted August 17, 2006 Thanks a lot bbaker, its sorted now, I just removed it like you said. Thanks ;D 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.