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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:07:37+00:00 2026-06-06T10:07:37+00:00

I am using a PHP while loop in order to get data from a

  • 0

I am using a PHP while loop in order to get data from a database. Ignoring the data that I’m retrieving from the database and concentrating on the amount of records I have fetched, which is 4.

I want to be able to take the 1st record and insert it into a div called “div1” and take the 2nd record and insert it into a div called “div2”, take the 3rd record and insert it into a div called “div3”.

When it comes to the 4th record I would like to insert it in to the div called “div1” and so on.

I’ve managed to get every 3rd result, so skipping the 1st and 2nd record and being able to do it with the 3rd using a snippet from the below code:

if ($i % 3 < 2) {

I’m having trouble adapting that to do what I want it to do.

  • 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-06T10:07:40+00:00Added an answer on June 6, 2026 at 10:07 am

    What you want is some variation of

    $targetDivNumber = ($i % 3) + 1;
    

    See it in action.

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

Sidebar

Related Questions

I've been trying to present my data from my database using PHP. My while
I'm using while($stmt->fetch()) to loop though the results I get from a MySQL Query,
Using PHP , I would like to make a while loop that reads a
I'm trying to display ul>li list using PHP while loop and MYSQL. My database
In PHP I'm using mysqli_fetch_assoc() in a while-loop to get every record in a
After using PHP for a while now, I've noticed that not all built-in PHP
So I have this simple PHP loop that is generating html table data with
I have a file ajax.php that needs to trigger a big while loop and
I am trying to display from a MySQL Database using PHP and Ajax but
I have a large PHP loop that I'm re-using in multiple spots on multiple

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.