Jump to content

Archived

This topic is now archived and is closed to further replies.

ScottRiley

Missing MySQL content

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

Share this post


Link to post
Share on other sites
Post the code that runs your querty, and we'll be on the right track to getting this figured out for you... ;)

Share this post


Link to post
Share on other sites
[code]$sql="SELECT * FROM southport_businesses";
$result=mysql_query($sql);
$rows=mysql_num_rows($result);
$array=mysql_fetch_array($result);
code]
[/code]

Share this post


Link to post
Share on other sites
WHen are u assigning a value to the variable $rows? Are you sure one of the username is not just a blank?

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites

×

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.