display different images for different categories

Discussion in 'PHP' started by zic74, Jul 28, 2012.

  1. #1
    could some one tell me the php if else statement to display different images for different subcategories. I have done the css part however not sure about the php coding.................................................................................................................................................................................................Let say for the category link "products.php?mcatid=5&scatid=1"i want to display the image1 and For the category link "products.php?mcatid=5&scatid=2"i want to display the image2 and so on.......................................................................................................................................................................................if category link (products.php?mcatid=5&scatid=1)echo 'class="Header1"';else if if category link (products.php?mcatid=5&scatid=2)echo 'class="Header2"';else echo 'class="Header-jpeg"';
     
    Solved! View solution.
    zic74, Jul 28, 2012 IP
  2. #2
    I suggest you do it like this:

    <?php
    if($_GET['scatid']==1){
    $class = "Header1";
    }
    else if($_GET['scatid']==2){
    $class = "Header2";
    }
    ?>

    <div class="<?php echo $class; ?>"></div>


    in my opinion that's cleaner.
     
    Arttu, Jul 28, 2012 IP
  3. zic74

    zic74 Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thank you for this great solution.It works perfectly what i wanted to do.
     
    zic74, Jul 29, 2012 IP