Jump to content

Missing MySQL content


ScottRiley

Recommended Posts

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 "&nbsp;&nbsp;&nbsp;&nbsp;".$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 advance
Scott
Link to comment
https://forums.phpfreaks.com/topic/17744-missing-mysql-content/
Share on other sites

[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 "&nbsp;&nbsp;&nbsp;&nbsp;".$array['Username']."<BR>";
}
?>

[/code]
Link to comment
https://forums.phpfreaks.com/topic/17744-missing-mysql-content/#findComment-75783
Share on other sites

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.