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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:26:59+00:00 2026-05-26T13:26:59+00:00

I have this web page I’m developing that displays multiple images of one product

  • 0

I have this web page I’m developing that displays multiple images of one product in a sort of gallery. However I’m having great trouble trying to have the thumbnail images appear as the main image when clicked.

Here’s a link to the page in question: http://www.carbondelight.co.uk./prodview.php?id=50

I’m using the bxslider (bxslider.com) for the thumbnail slider, and my initial plan was to simply write some JavaScript that would change the main image to the relevant thumbnail image. Athough this is where I become stuck, as I can’t figure out a good way to achieve this.

I have looked at ways like setting all main images to display:none; bar one image and then altering their display attr via javascipt like Sohtanaka does in his tutorial(http://www.sohtanaka.com/web-design/css-multiple-image-viewer-thumbnails/) and I’ve looked at changing the src location of the main image with JavaScript.

I will say that I’m no pro with PHP or JavaScript so my code is in no way shape or form efficient, so I’d like to focus on simply getting the question at hand solved rather than changing all the code to make it more efficient. However if I have to rewrite some of the queries to make this work then I’m all ears.

How can I get the thumbnails and main images working?

NOTE: I have cleaned up the code and taken out some simple styling classes to make it more readable. And if it’s a benefit I can include the CSS as well.

Here’s my code:

if (isset($_GET['id']))
$id = cleanString($_GET['id']);

$sql = "SELECT * FROM partTable WHERE partID='$id'";
$result = performQuery($sql);

$sql2 = "SELECT car FROM carTable WHERE carID='$result[6]'";
$result2 = performQuery($sql2);

$sql3 = "SELECT category FROM categoryTable WHERE categoryID='$result[7]'";
$result3 = performQuery($sql3);

$sql4 = "SELECT medImg, lrgImg FROM imageTable WHERE partID='$id'";
$result4 = mysql_query($sql4);

$rows = mysql_num_rows($result4);

$sql5 = "SELECT smlImg FROM imageTable WHERE partID='$id'";
$result5 = mysql_query($sql5);

$rows5 = mysql_num_rows($result5);

$row = mysql_fetch_row($result4);
echo "<a id='single_image' href='$row[1]'><img src='$row[0]' /></a>"; 

for ( $j = 1 ; $j < $rows ; $j++)
{
    $row = mysql_fetch_row($result4);
    echo "<a id='single_image' href='$row[1]'><img style='display:none;' src='$row[0]'/></a>"; 
}


echo "<div id='slider1'>";

for ( $j = 0 ; $j < $rows5 ; ++$j)
{
    $row = mysql_fetch_row($result5);
    echo "<div class='pv-thumb'><a href='javascript:void(0)' onclick='superalert()'><img  src='$row[0]'  /></a></div>";
}

echo "</div>";
  • 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-26T13:27:00+00:00Added an answer on May 26, 2026 at 1:27 pm

    OK, so this is a JavaScript question. To make life easy for yourself, get yourself a copy of jQuery, and then you can do this:

    // Wait for document ready
    $(document).ready(function() {
        // Attach to all thumbnails (give all images a class of 'thumbnail')
        $('img.thumbnail').click(function() {
            // Let us assume your thumbs and medium images are thus:
            // Thumb: /admin/image/proSml/96.jpg
            // Medium: /admin/image/proMed/96.jpg
    
            // Reset source of main image based on thumbnail
            var thumbSrc = $(this).attr('src');
            var medSrc = thumbSrc.replace('proSml', 'proMed');
            $('#mainimage').attr('src', medSrc);
        });
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this web page that works fine in one webhost but not in
I have a web page that consists of a checkbox (parent) and on this
I have an image on my web page like this: <img src=/Images/content/home.png alt= style=float:
I have to create a web page that for the purposes of this question
I have this web page that begins with <!-- DOCTYPE html --> , which
On this web page I have a copy function that uses flash swf. I
I have a web page. When this web page is loaded, I want to
I have this web application using Spring Web Flow framework. In my main page
I have a very general web page where I display information. I have this
I have used this code for extracting urls from web page.But in the line

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.