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

  • Home
  • SEARCH
  • 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 355567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T12:01:48+00:00 2026-05-12T12:01:48+00:00

For some reason I’m having a problem retrieving data from my database. It leaves

  • 0

For some reason I’m having a problem retrieving data from my database. It leaves off the first item being listed.

Connection:

mysql_select_db($database_my_db, $my_db);

    $query_rs_jobboards11 = "SELECT * FROM jobBoardsSpecTypes ORDER BY type";
    $rs_jobboards11 = mysql_query($query_rs_jobboards11, $my_db) or die(mysql_error());
    $row_rs_jobboards11 = mysql_fetch_assoc($rs_jobboards11);
    $totalRows_rs_jobboards11 = mysql_num_rows($rs_jobboards11);

Output:

 <form action="" method="get">
        <select name="specialty">

         <?php do { ?>

    <option value="<?php echo $row_rs_cms11['type']; ?>"><?php echo $row_rs_cms11['type']; ?></option>


    <?php } while ($row_rs_cms11 = mysql_fetch_assoc($rs_jobboards11)); ?> 


        </select>

<input type="submit" value="Go" />

</form>

It keeps leaving out the first entry in the type column. If I add more entries, then the one that was left out previously is shown, and the new entry is hidden.

What am I doing wrong? The database works perfectly fine for everything but this page.

  • 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-05-12T12:01:48+00:00Added an answer on May 12, 2026 at 12:01 pm

    You already assigned the first row to $row_rs_jobboards11, so when you call $row_rs_cms11 = mysql_fetch_assoc($rs_jobboards11) in your do/while loop, it’s starting at the second row in the table.

    Using a do/while instead of a while doesn’t make any difference, but using different variable names does make a difference.

    Update, to explain the difference between while, do/while, and, making sure your variable names are correct.

    While loop, which works:

    while ($row_rs_cms11 = mysql_fetch_assoc($rs_jobboards11)) {
        echo '<tr>';
        //stuff here
        echo '</tr>';
    }
    

    do/while loop, which also works

    $row_rs_cms11 = mysql_fetch_assoc($rs_jobboards11);
    do {
        echo '<tr>';
        //stuff here
        echo '</tr>';
    } while ($row_rs_cms11 = mysql_fetch_assoc($rs_jobboards11));
    

    Note that the $row variable matches. If you leave out the first call, it will still work, but you’ll get an extra (empty) before any content is outputted. If you set the variable to a different name (and use a mysql_fetch_* call), the internal database pointer is set to the second row in the table. Consequently, you miss the first row in the table, because it’s set to a different (unused) variable.

    Moral of the story:

    You can use either a while or a do/while loop, you just have to make sure that

    • If you are using a do/while, the row variable must be created prior to entering the loop. And,
    • Make sure your variable names match!
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 213k
  • Answers 213k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If you have an array of "something" that comes from… May 12, 2026 at 10:36 pm
  • Editorial Team
    Editorial Team added an answer I was able to do it using <target name="run" depends="compile">… May 12, 2026 at 10:36 pm
  • Editorial Team
    Editorial Team added an answer Based on what you described, the driver uses the OS… May 12, 2026 at 10:36 pm

Related Questions

For some reason I never see this done. Is there a reason why not?
For some reason I am having troubles with a DBI handle. Basically what happened
For some reason I can't find a way to get the equivalents of sqlite's
For some reason I'm not getting this. (Example model below) If I write: var
For some reason I can't use runat=server as an attribute for the input tag

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.