Hello everyone, hoping someone could possibly take a minute and see what it takes to get this working.
I am trying to make the menu structure that I need into an XML file.
the database looks like this:
itemID = the primary key, autoincrement field, of each item
Parent_field = 0 if it is a root menu, otherwise the itemID it is tied to.
menuname = just the name of the menu item
so far, I have this code that seems to be starting it, but it seems to be over my head as I am a novice with PHP...
php:
<?php
//header("Content-type: text/xml");
$host = "192.168.2.2";
$user = "testuser";
$pass = "testuser";
$database = "testdb";
$linkID = mysql_connect($host, $user, $pass) or die("Could not connect to host.");
mysql_select_db($database, $linkID) or die("Could not find database.");
$xml_output = "<?xml version=\"1.0\"?>\n";
$xml_output .= "<menu name=\"links\">\n";
$query1 = mysql_query("SELECT FROM menusystem WHERE Parent_field = 0");
for($i=0; $i<mysql_num_rows($query1); $i++)
{
$query2 = mysql_query("SELECT FROM menusystem WHERE Parent_field = itemID");
$xml_output .= "<menu name='".mysql_result($query1,$i,"menuname")."'>";
for($j=0; $i<mysql_num_rows($query2); $j++)
{
$xml_output .= "\t<item name='".mysql_result($query2,$j,"menuname")." ....... '>";
}
$xml_output .= "</menu>";
}
$xml_output .= "</menu>";
echo $xml_output;
?>
The main problem I am having is that it must have sub menus and then sub sub menus in it. Notice how each menu uses a <menu> tag and if it is an item, it uses an <item> tag.
Here is a sample of the output I need it to be in... any suggestions would be lovely...
code:
<?xml version="1.0"?>
<menu name="links">
<item name="Carabiners" action="getRecords" variables="Carabiners"/>
<item name="Harnesses" action="getRecords" variables="Harnesses"/>
<item name="Quick Draws" action="getRecords" variables="Quick Draws"/>
<item name="Ropes" action="getRecords" variables="Ropes"/>
<menu name="Miscellaneous" action="getRecords" variables="Miscellaneous">
<menu name="Colors">
<item name="White" action="getSubSubRecords" variables="White"/>
<item name="Black" action="getSubSubRecords" variables="Black"/>
<item name="Blue" action="getSubSubRecords" variables="Blue"/>
<item name="Green" action="getSubSubRecords" variables="Green"/>
</menu>
<menu name="More Colors">
<item name="White" action="getSubSubRecords" variables="White"/>
<item name="Black" action="getSubSubRecords" variables="Black"/>
<item name="Blue" action="getSubSubRecords" variables="Blue"/>
<item name="Green" action="getSubSubRecords" variables="Green"/>
</menu>
<menu name="More Colors">
<item name="White" action="getSubSubRecords" variables="White"/>
<item name="Black" action="getSubSubRecords" variables="Black"/>
<item name="Blue" action="getSubSubRecords" variables="Blue"/>
<item name="Green" action="getSubSubRecords" variables="Green"/>
</menu>
<menu name="Manufacturer">
<item name="Black Diamond" action="getManufacturer" variables="Black Diamond"/>
<item name="Petzl" action="getManufacturer" variables="Petzl"/>
</menu>
<item name="Professional" action="getSubRecords" variables="Professional Series"/>
<item name="Intermediate" action="getSubRecords" variables="Intermediate Series"/>
<item name="Sport" action="getSubRecords" variables="Sport Series"/>
<item name="Beginner" action="getSubRecords" variables="Beginner Series"/>
</menu>
</menu>