Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7911199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:09:26+00:00 2026-06-03T13:09:26+00:00

I’m not really sure what the problem is here, I have a posts table

  • 0

I’m not really sure what the problem is here, I have a posts table that has a foreign key of userid and I want to pull their usernames from the users table based on that, it seems to pull them out fine but it won’t display on the first post.
My code is:

$query_therealuserid = 'SELECT users.username, users.userid, posts.userid, posts.created_at
FROM users, posts
WHERE users.userid = posts.userid
ORDER BY posts.created_at';

$therealuserid = mysql_query($query_therealuserid, $akaearthdb) or die(mysql_error());

and

<?php do { ?>
  <div id= "post">
    <?php if (stripos($row_rsjustpost['link'], ".png") !== false) {?>
            <img src="<?php echo $row_rsjustpost['link']; ?>" id="postImage" alt="Broken Link">
            <?php }?>
    <?php if (stripos($row_rsjustpost['link'], ".gif") !== false) {?>
            <img src="<?php echo $row_rsjustpost['link']; ?>" id="postImage" alt="Broken Link">
            <?php }?>
    <?php if (stripos($row_rsjustpost['link'], ".jpg") !== false) {?>
            <img src="<?php echo $row_rsjustpost['link']; ?>" id="postImage" alt="Broken Link">
            <?php }?>
    <?php if (stripos($row_rsjustpost['link'], ".jpeg") !== false) {?>
            <img src="<?php echo $row_rsjustpost['link']; ?>" id="postImage" alt="Broken Link">
            <?php }?> 

    <a href="<?php echo $row_rsjustpost['link']; ?>"><?php echo $row_rsjustpost['title']; ?></a>
    <br/>
    <?php echo $row_rsjustpost['text']; ?>
    </p>
    <br />

            <?php 
            do {
            if ($whileLoopCounter0!=$whileLoopCounter1){break;}
        ?>By: <?php echo $row['username'];
        echo "<br />";
            $whileLoopCounter1++;

            } while($row = mysql_fetch_array($therealuserid));
            ?>


  </div>
  <?php $whileLoopCounter0++; ?>
  <?php } while ($row_rsjustpost = mysql_fetch_assoc($rsjustpost)); ?>
</div>

when I pull up the page I get all the posts but the first one doesn’t have a username and the usernames are all pushed down one post. The first post has a postid of 2, if I create a new post with a postid of 1 and a userid it shows up at the top without a username and the others usernames are moved up so that they are corect.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T13:09:27+00:00Added an answer on June 3, 2026 at 1:09 pm

    You’re currently using a do-while loop, so first the do block is executed and then the while block is evaluated only after the 1st execution of the do block.

    Use this instead:

    while ($whileLoopCounter0==$whileLoopCounter1) {
       $row = mysql_fetch_array($therealuserid);
       if ($row){
     ?>
     By: 
     <?php 
          echo $row['username'];
          echo "<br />";
          $whileLoopCounter1++;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I want to count how many characters a certain string has in PHP, but
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I need a function that will clean a strings' special characters. I do NOT
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have just tried to save a simple *.rtf file with some websites and
Basically, what I'm trying to create is a page of div tags, each has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.