View Full Version : Generating DIVS

11-10-2011, 02:48 AM
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
height: 25px;
width: 100px;
border:1px solid #000;
-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.

11-10-2011, 03:01 AM
This should get you going


$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>';


11-10-2011, 08:40 PM
Sweet. Much appreciated.