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 Link to comment https://forums.phpfreaks.com/topic/17744-missing-mysql-content/ 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... ;) Link to comment https://forums.phpfreaks.com/topic/17744-missing-mysql-content/#findComment-75705 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] Link to comment https://forums.phpfreaks.com/topic/17744-missing-mysql-content/#findComment-75743 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? Link to comment https://forums.phpfreaks.com/topic/17744-missing-mysql-content/#findComment-75781 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] Link to comment https://forums.phpfreaks.com/topic/17744-missing-mysql-content/#findComment-75783 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 Link to comment https://forums.phpfreaks.com/topic/17744-missing-mysql-content/#findComment-76096 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.