Milonic provide full featured pull down web menus for some of the worlds largest companies
click here to see what it can do for you

Download Milonic DHTML Menu
Buy Milonic DHTML Menu

Back To Start Of Archive
Taken From The Forum: Help & Support for DHTML Menu Version 5+
Forum Topic: Click to view post
Last Updated: Saturday July 14 2012 - 06:07:39

PHP function() {


Poster: slackbladder
Dated: Friday July 1 2005 - 15:44:11 BST

Hi,

Is it possible to use the menu with PHP function name() { to call the menu files (js)? I am using the PHP_MYSQL solution.

EXAMPLE:

INDEX.PHP
Code:
<?php

function home(){
include('header.php');
echo "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n";
echo "<tr><td valign=\"top\">\n";
PAGE CONTENT
echo "</td></tr>\n";
echo "</table>\n";
}

switch ($name) {

default:
    home();
    break;     
}
?>




HEADER.PHP
Code:
<?php
echo "<head>etc\n";
echo "<body>etc\n";

include("mm_config.php");  // This file contains all of the user editable parameters
include("mm_phpmenu.php"); // This is the file containing all of the PHP functions
buildMySQLMenu(1); // This line builds the menu from MySQL data tables.


?>


It works fine having the index.php file call another PHP file header.php containing the menu calls but if you use functions (function name() { ) in the index.php to call header.php it doesn't work.

Bugger!! does anyone understand what I mean and can you help?

Thx


Poster: slackbladder
Dated: Friday July 1 2005 - 15:50:29 BST

Typical!! :?

Takes me 1/2 an hour to try to explain the problem - then I solve it myself straight after!!! :x :D

If anyone else is having the same problem, adding:

Code:
global $menuVars;


at the top of your 'function' fixes it (well did for me anyway) :D


Poster: Andy
Dated: Monday July 4 2005 - 9:56:57 BST

That gets a lot of people, variables, in PHP, are not global by default and need to be declared as global inside functions.

Thanks for posting the fix.

Cheers,
Andy