Forum Moderators: coopster

Message Too Old, No Replies

Help with dynamic menu

Im using php to echo my menu but i need help

         

riggerz29

12:20 pm on Nov 26, 2009 (gmt 0)

10+ Year Member



Im using php to echo my menu but i need help with the styling of it.

Here is my code to gather my menu along with its style

$menuDisplay .= '<ul class="MenuBarVertical"><li><a href="categories.php?catid='. $cid .'">'. $name .'</a></li></ul>';

the trouble is with the </ul> which is echoing after each menu link so i have a space inbetween each menu link

would it be easier if i used a tabbed panel group

any help would be greatly appriciated.

rocknbil

4:39 pm on Nov 26, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Just put the opening and closing ul outside your loop. If you already have it in an array, use that instead of the database demonstrated.


$menuDisplay = '<ul class="MenuBarVertical">';
$query = "select cat_id,cat_title from categories order by name";
$result=@mysql_query($query);
if (!$result) { echo "No categories available"; }
while ($row=mysql_fetch_array($result)) {
$cid = $row[0]; // or $row['cat_id']
$name = $row[1]; // or $row['cat_title']
$menuDisplay .= '<li><a href="categories.php?catid='. $cid .'">'. $name .'</a></li>';
}
mysql_free_result($result);
$menuDisplay.= '</ul>';

riggerz29

8:20 am on Nov 27, 2009 (gmt 0)

10+ Year Member



Thanks so much for your reply rocknbil i have adjusted my code and my menu functions great but the gap inbetween each menu link still appears, everything is working mind you just not looking exactly how i want it.

Example how i would like it to display

LPG (GAS)
ELECTRIC
REACH TRUCKS

Here is how it is displaying

LPG (GAS)

ELECTRIC

REACH TRUCKS

Any ideas because im lost as im not brilliant at php

rocknbil

9:58 pm on Nov 27, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This may or may not be a PHP problem. When you view source, what do you see?

<ul>
<li>item 1</li>
<li>item 2</li>
<li>item 3</li>
</ul>

If it looks like this, it's not a problem in PHP, it's a problem with the CSS.