从php执行url脚本

I am trying to dynamically load a php form from a selected menu option, drawing the relevant form name from a mysql database and then loading the file. If relevant the actual php form is held outside the database in a directory.

I have the following line of code which I've been playing around with but to no avail

<a href="$submenu["form_name"]">$submenu["menu_name"]</a>

where $submenu is an associative array with an element called 'form_name'. This is the database field which contains the php form I'm trying to load into the 'a href'. It also contains the element called 'menu_name' which is just text. The array works as I've tested it by loading a generic script and drawing the row id from the database but written this way its complaining that the $submenu variable is unexpected.

<a href="<?=$submenu["form_name"]; ?>"><?=$submenu["menu_name"]; ?></a>

If you're working inside <?php ?> code blocks, this should do it:

<?php
    // ......
    echo "<a href=\"{$submenu['form_name']}\">{$submenu['menu_name']}</a>";
    // ......
?>

Try like this:

<a href="<?php echo $submenu["form_name"]; ?>"><?php echo $submenu["menu_name"]; ?></a>