SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Wizard
    Join Date
    May 2012
    Posts
    1,107
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Associative Menu

    Hi,

    I need some help in my menu how can i navigate to other page using this associative array,please help me i am confuse.

    Code:
     <?php
         $myMenu = array("home"      =>    "home.php",
                            "gallery"    =>     "Gallery.php",
                            "contact"  =>     "Contact.php".
                            "about"     =>     "About.php");
    
    ?>
    
    in my html tag
    ....
    ...
       <body>
             <a href="index.php?page=home>Home</a>
             <a href="index.php?page=gallery>Gallery</a>     
             <a href="index.php?page=contact>Contact</a>
             <a href="index.php?page=home>About</a>
    
    
      </body>

  2. #2
    Non-Member
    Join Date
    Feb 2012
    Posts
    892
    Mentioned
    10 Post(s)
    Tagged
    0 Thread(s)
    <body>
    <?php
    foreach($myMenu as $menuKey => $menuItem){
    echo '<a href="'.$menuItem.'">'.$menuKey.'</a>';
    }
    ?>
    <body>

  3. #3
    SitePoint Wizard
    Join Date
    May 2012
    Posts
    1,107
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Hi,Thank you for this okay i will try this one...

  4. #4
    SitePoint Wizard
    Join Date
    May 2012
    Posts
    1,107
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by itmitică View Post
    <body>
    <?php
    foreach($myMenu as $menuKey => $menuItem){
    echo '<a href="'.$menuItem.'">'.$menuKey.'</a>';
    }
    ?>
    <body>
    Hi, sorry for the late reply...i have question on your solution,how can i display in the url like this

    index.php?page=home

    This is what i want to achieve...I hope you can help me.Thank you in advance.


Bookmarks

Posting Permissions

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