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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T10:34:06+00:00 2026-06-02T10:34:06+00:00

I have a jquery carousel set to 620px wide. I am using the grid

  • 0

I have a jquery carousel set to 620px wide. I am using the grid 960 to place the images inside. I show 4 images at a time.

In order to do that I set the every first image class to ‘grid_2 alpha’ and every fourth to ‘grid_2 omega’ in the group of 4 shown while all in between I set to just grid_2.

This gives me the 620px I need. I am pulling from the database and I am trying to set the class dynamically but cant quite get every first and fourth in the group with the classes.

                    <?php $loopIndex = 1; ?>
                    <?php foreach ($pub_values as $v) { 
                    if($v['pub_of_the_month'] == 1)
                    {
                    ?>
                    <?php if ($loopIndex == 1 || $grid_class=="grid_2 omega") $grid_class="grid_2 alpha";
                            else if($loopIndex%4 == 0) $grid_class="grid_2 omega"; 
                            else $grid_class="grid_2"; 
                          $filename = "images/pub_images/120x160/".$v['id'].".jpg";
                          if (!file_exists($filename)) $filename = "images/pub_images/120x160/blank.gif";       
                    ?>
                        <div class="<?php echo $grid_class?>">
                            <a href="#">
                                <img src="<?=$filename;?>" alt="<?=$v['name'];?>" width="120" height="160" />
                                <?=$v['name'];?>
                            </a>
                        </div>
                    <?php $loopIndex = $loopIndex + 1; } }?>

The above code is my best attempt of achieving the following.

Images

1 – grid_2 alpha

2 – grid_2

3 – grid_2

4 – grid_2 omega

5 – grid_2 alpha

6 – grid_2

7 – grid_2

8 – grid_2 omega

9 – grid_2 alpha

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

    Simple math, dividing with a remainder.

    Maybe you can figure out by looking a this code:

    for($i = 1; $i <= 9; $i++){
        echo "\n $i ";
        if($i % 4 == 1){
            echo " alpha";
        }elseif($i % 4 == 0){
            echo " omega";
        }
    }
    

    Live example: http://codepad.org/LIepxlJm

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

Sidebar

Related Questions

I am using this jQuery Carousel inside a wordpress theme to show several banner
I have played around and implemented JQuery cycle to create a carousel with images,
I have a jQuery script that creates a carousel to rotate images left and
I'm using the jquery carousel and I have the image auto rotating here (
I have built a carousel using the jQuery cycle plugin. I have 4 links
I have a carousel with a set of thumbnails inside. When those thumbnails are
I have put together a couple of jquery carousel's using either Tiny Carousel or
Cheers, I have a strange side effect from a jQuery carousel I am using
I need to tweak a jQuery carousel I have made using the excellent cycle
i have this script found here http://jsfiddle.net/g4txt/ i am using this carousel http://www.thomaslanciaux.pro/jquery/jquery_carousel.htm the

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.