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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:50:21+00:00 2026-06-18T14:50:21+00:00

I have a php script that calls a series of images that display as

  • 0

I have a php script that calls a series of images that display as so:

This is the php code that calls them:

<?php

$query = "SELECT
parent_business_id,
image_url,
alt_tag,
description,
thumb_url,
business
FROM
images
ORDER BY
RAND()
LIMIT
6
";

$result = mysql_query($query, $dbc)
or die (mysql_error($dbc));

while($row = mysql_fetch_array($result)) {

$parent = $row["parent_business_id"];
$image = $row["image_url"];
$alt = $row["alt_tag"];
$description = $row["description"];
$thumb = $row["thumb_url"];
$business = $row["business"];

$mainthumb = "./images/270x270/$image.jpg";

echo

"<div class='gallery_image_container'>

<a href='business-profile.php?business_id=$parent' class='gallery_darken'><img src='$mainthumb' alt='$alt' title='$description' /></a>

</div>";

}

?>

At the moment I am using css3’s nth-child to add margins to the central images:

div.gallery_image_container:nth-child(3n+2){
margin-left:10px;
margin-right:10px;
}

The problem I have is this works great in browsers that support css3 but ie 7 and ie 8 will not and I need a solution. I am thinking that maybe I can do this by adding classes in php. If so which function would I use. Is there an nth-child like selector in php?

  • 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-18T14:50:23+00:00Added an answer on June 18, 2026 at 2:50 pm

    As Andy mentioned in the comments you can find out to which elements you have to add a class with PHP. All you need is a modulo division.

    A pure CSS-Solution requires you to improve your HTML. It is obviously a list of images, therefore: Use a list. The resulting HTML should look something like this:

    <ul class="gallery_container">
        <li>
            <a href='business-profile.php?business_id=$parent' class='gallery_darken'><img src='$mainthumb' alt='$alt' title='$description' /></a>
        </li>
        <li>
            <a href='business-profile.php?business_id=$parent' class='gallery_darken'><img src='$mainthumb' alt='$alt' title='$description' /></a>
        </li>
        <li>
            <a href='business-profile.php?business_id=$parent' class='gallery_darken'><img src='$mainthumb' alt='$alt' title='$description' /></a>
        </li>
        […]
    </ul>
    

    In the CSS now remove your :nth-child rule and instead add the following two rules:

    .gallery_container {
        margin: 0 0 0 -20px;
        padding: 0;
        list-style: none;
    }
    .gallery_container > li {
        margin: 0 0 0 20px;
        padding: 0;
        float: left;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In php I have a script, that I use mod_rewrite to redirect all calls
I have a basic php script that calls system(netstat -l) and the reads what
I have some problems with a PHP script that calls a Bash script.... in
i have a java applet that calls this url that links to a php
I have a simple jQuery post function that calls PHP script in order to
I have a PHP script that calls MySQL's LOAD DATA INFILE to load data
I have a script that calls a php page via jquery/ajax. The results would
I have a phone system that calls a PHP script to send an email
I have a code that post to a php script that reads all files
Hello I have a script that uploads multiple images (this script is composed of

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.