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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:16:47+00:00 2026-06-04T04:16:47+00:00

I currently have a loop of items being shown on a page. I would

  • 0

I currently have a loop of items being shown on a page.

I would like to run the loop twice (output 2 results/items), and THEN insert a banner ONCE right after the 2nd result, and THEN let loop continue from where it left off.

An illustration below:

{— START OF LOOP —}

ITEM 1 | ITEM 2
{ BANNER HERE }
ITEM 3 | ITEM 4
ITEM 5 | ITEM 6
ITEM 7 | ITEM 8

{— END OF LOOP —}
<- prev | next ->

The items are inside a while loop:

$sql = mysql_query("SELECT id, img, description, keyword, category FROM images WHERE connect = 1 ORDER BY id DESC LIMIT $from , $perPage");

while($result = mysql_fetch_object($sql)) {
LOOP OF ITEMS HERE }

I’ve only ever found “do” / “while” methods, which isn’t really what I’m looking for.
If anyone could help, thank you for your time & assistance.

  • 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-04T04:16:48+00:00Added an answer on June 4, 2026 at 4:16 am
    $i=1;
    while($result = mysql_fetch_object($sql)) {
        //print item
        if($i==2) { 
            //print banner
        }
        $i++;
    }
    

    if you want it to print every 2 items the yu can use

    if($i % 2 == 0)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently I have a loop that tries to find an unused filename by adding
Currently, I have a while loop for listening the port. When a socket accepta
Currently have password protection on my main and sub directories, however I'd like to
I currently have a query that looks like this: SELECT NON EMPTY ([Measures].[TOTAL]) ON
Here I have an output from a website using Soap stdClass Object ( [page]
I currently have a 2-column wide DataGridView, the first column being a DataGridViewTextBoxColumn and
I am using C#. I have a list of items. I loop through each
I currently have this: $.getJSON('test.json', function(data) { var items = []; $.each(data, function(key, val)
I currently have 4 textboxes which will be used to store an ip address.
I currently have a Gridview , And I want to use client-side validation to

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.