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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.