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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:17:35+00:00 2026-05-17T15:17:35+00:00

I have the following structure: Table: products id, name, sort_order Let’s say I only

  • 0

I have the following structure:

Table: products

id, name, sort_order

Let’s say I only have 5 products, but I want 20.

How would I loop through to get 20 results?

Additionally, I’ll need to start at a specific sort_order. So let’s say I have

1,2,3,4,5

and I want to get 20 results and start at 3. It should end up as:

3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,etc.

Any ideas? I’m totally lost.. thank you!

  • 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-17T15:17:35+00:00Added an answer on May 17, 2026 at 3:17 pm
    $how_many = 20;
    $counter = 0;
    $rows = array();
    
    $result = mysql_query("Your query");
    while($row == mysql_fetch_row($result)) {
      $rows[] = $row;
    }
    
    $expanded = array();
    for($i = 0; $counter < $how_many; $counter++) {
      $expanded[] = $rows[$i];
      $i++;
      if($i == count($rows)) {
        $i = 0;
      }
    }
    

    And now $expanded is filled with those 5 rows for 4 times.

    Edit: and don’t forget to adjust $i to your start element. For your example that would mean $i = 2 (third element).

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

Sidebar

Related Questions

Lets say I have the following MySQL structure: CREATE TABLE `domains` ( `id` INT(10)
I have a table emp with following structure and data: name dept salary -----
I have created a table in MSSQL having following structure - **Table Name -
I have following table structure in my DB ID Name -------------------------- ID_1 Name1 ID1
I have the following database structure (simplified) Store StoreId RateId Products ProductId Name Rates
I have two mysql tables that have the following structure: Table 1: ---ID---------NAME------- ---1-----
I have following table structure ID Name Parent_ID 1 abc 0 2 efg 1
i have a table of the following structure id name field1 field2 field3 1
I have following table structure: Table: Plant PlantID: Primary Key PlantName: String Table: Party
I have the following table structure CREATE TABLE `table` ( `id` int(11) NOT NULL

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.