Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 5 of 5

Thread: How to do this?

  1. #1
    Join Date
    Nov 2006
    Location
    D?sseldorf
    Posts
    2,858
    Tokens
    2,256

    Latest Awards:

    Default How to do this?

    Right, I have this code to define a title on a div;

    PHP Code:
    <?php
               
               
    if(!$_GET['page']) {
              echo 
    "Homepage";
               }
               elseif(
    $_GET['page']) {
                   if(
    $_GET['subpage']) {
                       
    $page_name str_replace("_"" "$_GET['page']);
                       
    $subpage_name str_replace("_"" ",$_GET['subpage']);
                   echo 
    strtoupper($page_name." - ".$subpage_name);
                   }
                   elseif(!
    $_GET['subpage']) {
                       if(
    $_GET['page'] == "ADMINISTRATIONCENTRE")
                       {
                            echo 
    strtoupper("ADMINISTRATION CENTRE");
                       }
                       else
                       {
                       echo 
    strtoupper($_GET['page']);
                       }
                   }
               }
              
    ?>
    Now, what I want another code to do is show an image defined by the page&subpage so it would be something like

    <img src="images/$page_name;$subpage_name;.png"> if you get me..
    Can anyone help?

  2. #2
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    Try this...

    PHP Code:
    $page $_GET["page"];
    $subpage $_GET["subpage"];

    if (!
    $page) {
        
    $page_name "Homepage";
        echo 
    $page_name;
        echo 
    "images/homepage.png";
    } else {
        if (
    $subpage) {
            
    $page_name str_replace("_"" "$page);
            
    $subpage_name str_replace("_"" "$subpage);
            echo 
    strtoupper($page_name " - " $subpage_name);
            
            echo 
    "images/{$page_name}-{$subpage_name}.png";
            
        } else {
            if (
    $page == "ADMINISTRATIONCENTRE") {
                echo 
    strtoupper("ADMINISTRATION CENTRE");
                echo 
    "images/{$page}.png";
            } else {
                echo 
    strtoupper($page);
                echo 
    "images/{$page}.png";
            }
        }


  3. #3
    Join Date
    Nov 2006
    Location
    D?sseldorf
    Posts
    2,858
    Tokens
    2,256

    Latest Awards:

    Default

    Think you missed the <img> tags out That's the bit i'm struggling with sorry ;p

    EDIT: Got it

    PHP Code:
    <?php $page $_GET["page"];
    $subpage $_GET["subpage"];

    if (!
    $page) {
        
    $page_name "Homepage";
        echo 
    '<img src="images/homepage.png">';
    } else {
        if (
    $subpage) {
            
    $page_name str_replace("_"" "$page);
            
    $subpage_name str_replace("_"" "$subpage);        
            echo 
    '<img src="images/' $page_name '' $subpage_name '.png">';
            } else {
    echo 
    '<img src="images/' $page_name '.png">';
            }
        }
        
    ?>
    Last edited by Luke; 28-11-2010 at 10:15 AM.

  4. #4
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    You don't have to keep breaking your echo '' for each variable... just use a ", and put {$page_name} and {$subpage_name}, makes it so much easier to read

    Concatenating strings is so much easier like that. I mean it's a personal preference I guess, but I think it looks better.

  5. #5
    Join Date
    Nov 2006
    Location
    D?sseldorf
    Posts
    2,858
    Tokens
    2,256

    Latest Awards:

    Default

    Quote Originally Posted by Dentafrice View Post
    You don't have to keep breaking your echo '' for each variable... just use a ", and put {$page_name} and {$subpage_name}, makes it so much easier to read

    Concatenating strings is so much easier like that. I mean it's a personal preference I guess, but I think it looks better.
    Fair enoughh, didn't know that
    cheers +rep

Posting Permissions

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