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 3 of 3

Thread: Generating DIVS

  1. #1
    New Coder
    Join Date
    Nov 2011
    Location
    Notre Dame, IN
    Posts
    16
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Generating DIVS

    Hello, I'm kind of new to php in theory I do understand it .I do know html and css , so i'm taking my first steps into php
    I'm creating a horizontal dynamic menu i've created 5 buttons straight in css out with divs, but it occurred to me that it'd be just easier to create only one div named button and create dynamically with php
    I include the button div in the menu div <php?
    include (includes/buttons/topmenubutton.php);?>
    And just to see how the button looks in the css file i'll post it here
    #topmenubutton{
    height: 25px;
    width: 100px;
    border:1px solid #000;
    border-top-left-radius:1em;
    border-top-right-radius:1em;
    background-color:#B0D1D8;
    -moz-box-shadow:2px 2px 9px #999;
    -webkit-box-shadow: 10px 10px 3px #000;
    My question is what would be the best way to create this button 5 times about 10 pixels apart and then have different text with links on each one.
    Last edited by SuperMode55; 11-10-2011 at 01:51 AM.

  • #2
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts
    This should get you going

    PHP Code:
    <?php
     
    $menuItems 
    = array (
      
    'Menu Item 1 Text' => 'http://www.link1.com',
      
    'Menu Item 2 Text' => 'http://www.link2.com',
      
    'Menu Item 3 Text' => 'http://www.link3.com'
    );
     
    foreach (
    $menuItems as $menuText=>$menuLink) {
      echo 
    '<div id="topmenubutton"><a href="' $menuLink '">' $menuText '</a></div>'
    }
     
    ?>
    Last edited by Spookster; 11-10-2011 at 02:07 AM.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • Users who have thanked Spookster for this post:

    SuperMode55 (11-10-2011)

  • #3
    New Coder
    Join Date
    Nov 2011
    Location
    Notre Dame, IN
    Posts
    16
    Thanks
    10
    Thanked 0 Times in 0 Posts
    Sweet. Much appreciated.


  •  

    Posting Permissions

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