Results 1 to 3 of 3

Thread: PHP novice having problems with a super simple image swap thingie

  1. #1

    PHP novice having problems with a super simple image swap thingie

    Hi, and sorry to trouble you with something this simple.

    I'm doing a design portfolio with lots of images.

    The basic layout is: large image on the left side, thumbnails for other views on the right side.

    How can I make a dynamic page that updates the large image when you click on thumbnails?

    What I've done so far is:

    PHP Code:
    <?php
    switch ($id) {
    case 
    "client1_01":
    $client_img "img_client1_01.jpg";
    break;
    case 
    "client1_02":
    $client_img "img_client1_02.jpg";
    break;
    default:
    $client_img "img_client1_01.jpg";
    }
    ?>
    HTML code that shows the large image:

    HTML Code:
    <img src="images/<?php echo $client_img ?>" alt=""/>
    HTML link syntax to update the large image:

    HTML Code:
    <a href="?id=client1_01"><img src="images/img_marker_90x70.gif"/></a>
    These are all in one file, index.php.

    It appears that when I click on a link and the url refreshes with the new var content (eg index.php?id=client1_01) it always runs the default case. Why is that?

    Thank you so much,
    mika

  2. #2
    well.... ummm... the image displayed for client1_01 and default are the exact same image... are you positive that it's calling the default? also you need to get the $id too... so you need to have
    PHP Code:
    $id $_GET['id']; 
    somewhere in your php... above your switch...
    Let us live so that when we come to die even the undertaker will be sorry. - Mark Twain
    Don't PM me your CSS, xHTML, JS or PHP questions. I will not reply to ANY IE6 questions.

  3. #3
    Quote Originally Posted by simplistik View Post
    well.... ummm... the image displayed for client1_01 and default are the exact same image... are you positive that it's calling the default? also you need to get the $id too... so you need to have
    PHP Code:
    $id $_GET['id']; 
    somewhere in your php... above your switch...
    PHP Code:
    $id $_GET['id']; 
    was exactly what I was looking for. Thanks!

    mika

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012