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 7856181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:37:25+00:00 2026-06-02T20:37:25+00:00

I have a for loop that displays the first six items in a MySQL

  • 0

I have a for loop that displays the first six items in a MySQL database. I then breakout to another piece of code, after which I have another for loop that displays the next six items in my database.

Though this is exactly the functionality that I wanted, I am confused as to how it works, and was hoping somebody could clarify for me. How does the second for loop know to start off where the first one left off?

My code is as follows:

for ($i = 1; $i <= 6; $i++) {
  $row = mysqli_fetch_array($result);

  $id = $row['id'];
  $title = $row['title'];
  $file = $row['file'];

  // Display items

}

The second for loop is exactly the same.

  • 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-02T20:37:27+00:00Added an answer on June 2, 2026 at 8:37 pm

    There is a resultset pointer that is created when you execute a query that returns a result set . Each call to mysqli_fetch_array advances the resultset pointer to next record

    When you are at the start of second for loop the result set pointer is pointing the 7th record

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have here a foreach loop that displays images from a database onto a
I have a loop that goes through all the news items we have on
I have a PHP loop that displays data for a particular posting on my
Hello i have this foreach loop that gives weird result , it displays only
I have a 'For' loop that displays pages in a Wizard. The loop looks
I have just started my first CI app. I have a view that displays
I'm using Entity Framework Code First to generated my database, so I have an
I have a script that uses a simple while loop to display a progress
I have a loop that finds duplicate lines in a .ini file. I can
I have a loop that runs through a variety of websites and I'd like

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.