Everybody! This is important. In a few days, these forums will be moving over to using the totally sweet Discourse platform. To ensure this migration happens smoothly with no loss of content, these forums are currently in a read-only mode. I do apologize for the inconvenience.

There is never a good time to turn the forums off for an extended period of time, but I promise the new forums will be a billion times better. I'm pretty sure of it.

See you all on the other side in a few days, and if you have any (non-technical) questions, please e-mail me at kirupa@kirupa.com. For technical questions, try to find a tutorial that corresponds to what you are looking for and post in the comments section of that page.

Cheers,
Kirupa

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