...

View Full Version : Generating DIVS



SuperMode55
11-10-2011, 01: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
#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.

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



<?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>';
}

?>

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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum