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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:42:44+00:00 2026-05-25T17:42:44+00:00

I am using cakephp and here is my sample code below along with the

  • 0

I am using cakephp and here is my sample code below along with the css i am doing

<div class="thumbs">
    <?php if(!empty($auction['Product']['Image']) && count($auction['Product']['Image']) > 0):?>
        <?php foreach($auction['Product']['Image'] as $image):?>
            <?php if(!empty($image['ImageDefault'])) : ?>
                <span><?php 
                    echo $html->link(
                        $html->image('default_images/'.$appConfigurations['serverName'].'/thumbs/'.$image['ImageDefault']['image']), 
                        '/img/'.$appConfigurations['currency'].'/default_images/max/'.$image['ImageDefault']['image'], 
                        array('class' => 'productImageThumb'), 
                        null, 
                        false);?>
                </span>
            <?php endif; ?>
        <?php endforeach;?>
    <?php endif;?>
</div>

.thumbs span //css for how to display the images
{
    float:left;
    width:75px; //this displays two images as a thumbnail in a single row
    margin:12px;
    border-right:1px solid #d5d5d5;
    padding:3px;
}

My problem is i want to do css border-right:none for all the images having count as even numbers. I tried using for loop in the span of my code but not getting the result. Please suggest me how to dynamically do css border-right for only thumb images of odd number count and not for even numbers.

  • 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-25T17:42:46+00:00Added an answer on May 25, 2026 at 5:42 pm

    Add the key to the foreach loop and add a new class to odd images using the key (assuming this is a standard Cake query result where the key reliably increments by one):

    foreach( $auction['Product']['Image'] as $key => $image ):
        $odd = ( $key % 2 ) ? ' oddImage' : '';
        ....
            array( 'class' => 'productImageThumb'.$odd ), 
        ....
    
    .oddImage {
        border-right:1px solid #d5d5d5;
    }
    

    (Protip: You don’t have to wrap every line of PHP into <?php ... ?> tags. The code will be much more readable if you close the PHP tags only when you need to output pure HTML.)

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

Sidebar

Related Questions

I have the following form in cakephp: <div class=quickcontactDisplay> <?php echo $form->create('Enquiry',array('action'=>'add','class'=>'quickcontact')); echo $form->hidden('visitor_id',
I want to run a web application on php and mysql, using the CakePHP
In a CakePHP 1.2 app, I'm using <?php $session->flash();?> to output messages like Record
As part of a larger web-app (using CakePHP), I'm putting together a simple blog
I work on a Webproject using jQuery and CakePHP. I use jeditable as an
I'm using the cacheCounter in CakePHP , which increments a counter for related fields.
I am using a very intrinsic database with a CakePHP application and so far
I am using cakephp 1.26 to create a simple message board in my localhost.
I'm writing a simple web application using CakePHP version 1.2 (the latest) and am
I am using cakePHP 1.26. I got a simple Table with some data in

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.