Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 12 of 12
  1. #1
    Regular Coder
    Join Date
    Jan 2010
    Posts
    127
    Thanks
    9
    Thanked 0 Times in 0 Posts

    multiple image script in dynamic website

    how can i make a specific image for specific page?

    example:
    http://example.com/index.php?page=home <-- use Image1 as logo
    http://example.com/tour.php?page=country <-- use Image2 as logo
    http://example.com/special.php?page=1 <-- use Image3 as logo

    all is a dynamic script no database driven, and i only use one header.php
    all my index.php tour.php and special.php include header.php only

    so is it possible php do what i want?

  • #2
    Senior Coder
    Join Date
    Sep 2010
    Posts
    1,915
    Thanks
    15
    Thanked 227 Times in 227 Posts
    This would not be very hard to do, but without looking at your current code, I can't suggest any specific code. You just have to use an if statement somewhere, it could be where the tag for the logo image is.

  • #3
    Regular Coder
    Join Date
    Jan 2010
    Posts
    127
    Thanks
    9
    Thanked 0 Times in 0 Posts
    all right here is my current coding

    index.php tour.php and service.php

    PHP Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">

    <head>
    <?php include("/inc/header.php"); ?>
    </head>

    <body>
    <?php include("/inc/navigation.php"); ?>
            <!-- :::: Begin Content :::: -->
        <?php
            $pass 
    = array('home','about','services','gallery','contact');
            if (
    in_array(@$_GET['page'], $pass)) { 
                include (
    $_SERVER['DOCUMENT_ROOT'] . '/gunungraya/page/' $_GET['page'] . '.php'); 
            } 
                elseif (!isset(
    $_GET['page'])) { 
                    include (
    $_SERVER['DOCUMENT_ROOT'] . '/gunungraya/page/home.php'); 
                } 
                   else { 
                     include (
    $_SERVER['DOCUMENT_ROOT'] . '/gunungraya/page/error.php'); 
                } 
        
    ?>
    <?php 
    include("/inc/footer.php"); ?>

    </body>

    </html>
    header.php

    PHP Code:
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
    <?php
    function title_switch(){
    $var = (isset($_GET['page']) && !empty($_GET['page']))?$_GET['page']:'home';
        switch( 
    $var ) {
            case 
    'home'
                
    $a['title'] = " » Homepage"
                
    $a['meta_d'] = "This page is about my site!"
                
    $a['meta_k'] = "something, somethingelse";
                
    $a['nivo'] = "<script src=\"./js/jquery.nivo.slider.pack.js\" type=\"text/javascript\"></script>\n";
                
    $a['nivo_css'] = "<link href=\"./css/nivo-slider.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />\n";
                break;
            case 
    'about'
                
    $a['title'] = " » About Us"
                
    $a['meta_d'] = "This page is about my site!"
                
    $a['meta_k'] = "something, somethingelse";
                break;
            case 
    'services'
                
    $a['title'] = " » Services"
                
    $a['meta_d'] = "This page is about my site!"
                
    $a['meta_k'] = "something, somethingelse";
                break;
            case 
    'gallery'
                
    $a['title'] = " » Gallery"
                
    $a['meta_d'] = "This page is about my site!"
                
    $a['meta_k'] = "something, somethingelse";
                break;
            case 
    'contact'
                
    $a['title'] = " » Contact Us"
                
    $a['meta_d'] = "This page is about my site!"
                
    $a['meta_k'] = "something, somethingelse";
                break;
            default: 
                
    $a['title'] = " » HTTP 404 - Page Not Found"
                
    $a['meta_d'] = ""
                
    $a['meta_k'] = "";
                break;
        }
        return 
    $a;
    }
    $details title_switch();
    ?>
    <meta content="<?php echo $details['meta_k']; ?>" name="keywords" />
    <meta content="<?php echo $details['meta_d']; ?>" name="description" />
    <link href="images/favicon.ico" rel="shortcut icon" />
    <link href="./css/style.css" rel="stylesheet" type="text/css" />
    <link href="./css/pirobox_lightbox.css" rel="stylesheet" type="text/css" />
    <script src="./js/jquery.min.js" type="text/javascript"></script>
    <script src="./js/jquery.easing.1.3.js" type="text/javascript"></script>
    <script src="./js/pirobox.min.js" type="text/javascript"></script>
    <script src="./js/global.js" type="text/javascript"></script>
    <?php echo $details['nivo_css']; ?><?php echo $details['nivo']; ?>
    <title>Gunung Raya Five Stars Express<?php echo $details['title']; ?></title>
    navigation.php

    PHP Code:
    <div class="main">
        <
    div class="header_resize">
            <
    div class="header">
                <
    div class="logo">
                    <
    a href="./">
                    <
    img alt="logo" border="0" height="100" src="images/logo.gif" width="500" /></a></div>
                <
    div class="clr">
                </
    div>
            </
    div>
        </
    div>
        <
    div class="body">
            <
    div class="menu_bar">
                <
    ul id="nav">
                    <
    li><a href="#">Parent 01</a></li>
                    <
    li><class="selected" href="#">Parent 02</a>
                    <
    ul>
                        <
    li><a href="#">Item 01</a></li>
                        <
    li><class="selected" href="#">Item 02</a></li>
                        <
    li><a href="#">Item 03</a></li>
                    </
    ul>
                    <
    div class="clear">
                    </
    div>
                    </
    li>
                    <
    li><a href="#">Parent 03</a>
                    <
    ul>
                        <
    li><a href="#">Item 04</a></li>
                        <
    li><a href="#">Item 05</a></li>
                        <
    li><a href="#">Item 06</a></li>
                        <
    li><a href="#">Item 07</a></li>
                    </
    ul>
                    <
    div class="clear">
                    </
    div>
                    </
    li>
                    <
    li><a href="#">Parent 04</a></li>
                    <
    li><a href="#">Parent 04</a></li>
                    <
    li><a href="#">Parent 04</a></li>
                    <
    li><a href="#">Parent 04</a></li>
                    <
    li><a href="#">Parent 04</a></li>
                    <
    li><a href="#">Parent 04</a></li>
                </
    ul>
                <
    div class="clr">
            </
    div>
        </
    div
    home.php

    PHP Code:
            <div class="body_resize">
                <
    div class="body_resize_top">
                    <
    div class="body_resize_bottom">
                    <!-- :::: 
    Nivo Slider :::: -->
                        <
    div id="slider" style="margin-top: 5px;">
                            <
    img alt="" src="./images/slider/slide1.jpg" />
                            <
    img alt="" src="./images/slider/slide2.jpg" />
                            <
    a href="./" title=""><img alt="" src="./images/slider/slide3.jpg" title="Lorem ipsum dolor sit amet, consectetuer adipiscing elit" /></a>
                        </
    div>
                        <
    p style="margin-top: 20px;">Commoveo wisi nulla pala illum melior quisEt luptatum validus wisi ingenium 
                        humo quidne
    eros lucidus dolore ea vel ametCaptopraemitto singularis tation 
                        duis consequat
    Jus vulputate ingenium mauris utveroEnim suscipit exerci eligo 
                        dolus decet elit transverbero
    . </p>
                        <
    p>Opto tegodistineo luptatumamet virtus ideo bene invindico eumVocoproprius
                        
    tation jugis dolore consequatadipiscing iusto euingenium augue nimisnostrud
                        
    lucidusQui tristique uxor ibidem iriure bis praesent osConsequat zelus pagus 
                        abdo augue demoveo odio jus vel
    . </p>
                        <
    p>Commoveo wisi nulla pala illum melior quisEt luptatum validus wisi ingenium 
                        humo quidne
    eros lucidus dolore ea vel ametCaptopraemitto singularis tation 
                        duis consequat
    Jus vulputate ingenium mauris utveroEnim suscipit exerci eligo 
                        dolus decet elit transverbero
    . </p>
                        <
    p>Opto tegodistineo luptatumamet virtus ideo bene invindico eumVocoproprius
                        
    tation jugis dolore consequatadipiscing iusto euingenium augue nimisnostrud
                        
    lucidusQui tristique uxor ibidem iriure bis praesent osConsequat zelus pagus 
                        abdo augue demoveo odio jus vel
    . </p>
                    </
    div>
                </
    div>
            </
    div>
            <
    div class="clr">
            </
    div
    footer.php

    PHP Code:
            <div class="footer">
                <
    div class="footer_resize">
                    <
    a href="#">
                    <
    img alt="picture" border="0" class="loggo" height="61" src="images/footer_logo.gif" width="322" /></a>
                    <
    class="right"><a href="#">
                    <
    img alt="picture" border="0" class="rss" height="16" src="images/rss_1.gif" width="16" /></a>
                    <
    a href="#">
                    <
    img alt="picture" border="0" class="rss" height="16" src="images/rss_2.gif" width="16" /></a>
                    <
    a href="#">
                    <
    img alt="picture" border="0" class="rss" height="16" src="images/rss_3.gif" width="16" /></a>
                    <
    a href="#">
                    <
    img alt="picture" border="0" class="rss" height="16" src="images/rss_4.gif" width="16" /></a
                      
    Copyright websitename All Rights Reserved<br />
                    <
    a href="#">Home</a> | <a href="#">Contact</a> | <a href="#">RSS</a></p>
                    <
    div class="clr">
                    </
    div>
                </
    div>
                <
    div class="clr">
                </
    div>
            </
    div>
        </
    div>
    </
    div

    i curently devoping offline file so i cant show u the site yet but attached togther is my screenshot of the web



    hope to hear from u soon, i willing to learn if u willing to teach me :x

  • #4
    Senior Coder
    Join Date
    Sep 2010
    Posts
    1,915
    Thanks
    15
    Thanked 227 Times in 227 Posts
    It's actually easier than I thought to make it work with your code, you don't even need to have any if statements. Just rename the logos you are using to home_logo.gif, about_logo.gif, services_logo.gif, etc, then change this line:
    PHP Code:
    <img alt="logo" border="0" height="100" src="<?php echo 'images/'.$var.'_logo.gif'?>" width="500" /></a></div>
    That should work fine.

  • #5
    Regular Coder
    Join Date
    Jan 2010
    Posts
    127
    Thanks
    9
    Thanked 0 Times in 0 Posts
    but i only using a navigation.php

    is it possible?

    because all my page will be like this

    example.com/index.php?page=home
    example.com/index.php?page=about
    example.com/tour.php?page=price
    example.com/service.php?page=range

    all index.php tour.php n service.php sharing a navigation.php where all my image file is located

  • #6
    Senior Coder
    Join Date
    Sep 2010
    Posts
    1,915
    Thanks
    15
    Thanked 227 Times in 227 Posts
    Is the index always using the same, logo, and tour always using the same logo? You can probably just add lines to the header php defining what logo to use in what case. Also, don't be afraid to just try it, it won't bite you. If what I suggested doesn't work we can refine things and try again.

  • #7
    Regular Coder
    Join Date
    Jan 2010
    Posts
    127
    Thanks
    9
    Thanked 0 Times in 0 Posts
    not working

    PHP Code:
    <a href="./"><img alt="logo" border="0" height="100" src="<?php echo './images/'.$var.'_logo.png'?>" width="600" /></a>
    the source

    Code:
    <a href="./"><img alt="logo" border="0" height="100" src="./images/_logo.png" width="600" /></a>

  • #8
    Senior Coder
    Join Date
    Sep 2010
    Posts
    1,915
    Thanks
    15
    Thanked 227 Times in 227 Posts
    Is $var defined before that code runs? Is the header included before it runs?

  • #9
    Regular Coder
    Join Date
    Jan 2010
    Posts
    127
    Thanks
    9
    Thanked 0 Times in 0 Posts
    yes or would u like to have a look at all i code? if yes i dont mind to email u.. because i kinda head now where did i go wrong

    sent u a pm have a look
    Last edited by lazyserv; 11-29-2010 at 05:50 PM.

  • #10
    Senior Coder
    Join Date
    Sep 2010
    Posts
    1,915
    Thanks
    15
    Thanked 227 Times in 227 Posts
    If I had looked more closely I would have seen that it was. OK, I see why it doesn't work, $var is contained in the function title_switch and so something has to be included in the switch statements instead ( probably easiest ) and returned along with all the other stuff. So you just need to add a line to the switch statements for each logo, and use that variable instead.

  • #11
    Regular Coder
    Join Date
    Jan 2010
    Posts
    127
    Thanks
    9
    Thanked 0 Times in 0 Posts
    sorry to say i really dont know how to do it... what line i should add it?

  • #12
    Senior Coder
    Join Date
    Sep 2010
    Posts
    1,915
    Thanks
    15
    Thanked 227 Times in 227 Posts
    We've got it. Change this line in your navigation:
    PHP Code:
    <img alt="logo" border="0" height="100" src="<?php echo './images/'.$details['logo']; ?>" width="600" /></a></div>

    Add this line to all the case statements, but choose the logo file name you want for each page.

    $a['logo'] = 'home_logo.png';
    You're welcome.

  • Users who have thanked DrDOS for this post:

    lazyserv (11-30-2010)


  •  

    Posting Permissions

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