I am attempting to make a website that will load a certain menu.xml doc, that was sent to it using a foreach loop. The foreach loop uses glob to grab all XML docs in a directory then prints the “name” attribute into a html link.
This has worked to up until the point were I need to pass the certain XML var used to make the link to another php doc that utilizes it.
I first attempted to use the $_SESSION to but could not as the loop would overwrite $_SESSION with each iteration. I also tried $_GET and $_POST, but I ran into the same problem with forms.
Here is my code (Please ignore any sloppyness, I am new to the PHP game):
foreach(glob("../menus/*xml") as $dom) //grabs each .xml doc in menus/
{
$menu = simplexml_load_file($dom); //loads the file into $menu
print "<li>";
print "<a href = menu.php>{$menu["name"]}</a>"; //links to page menu.php
print "</li>";
}
What I need this to do now, is to pass the individually loaded XML variable when the link is clicked.
How could I go about doing this?
Edit:
menu.xml is a page that displays the contents of the menu.xml.
Something like this?
The variable will be set into
$_GET['name']when the page is loaded.