Inspired by Lee Brimelow's video tutorial PHP, MySQL, and Flash, lets take a look at the steps necessary to pass your WordPress pages info into your own flash menu. Similar to the tutorial, the process is as follows: PHP gets the data from the mySQL database and outputs a structured XML document which Flash loads and displays its content.
We begin by understanding how and where our data is being stored. Pages are simply posts whose content is accessed and viewed differently from regular posts. In order for us to retrieve our Pages, we need to look at how WordPress database structure distinguishes between pages and posts. Start by opening your database with your preferred database management software, i am using phpMyAdmin, and open the *_posts table. Scroll through the columns until you get to post_type and scroll down; you will notice that which posts are pages and which are posts by the values post and page.

With an understanding of the structure we can now write our PHP code. Create a new file and save it as wpmenu.php; save it somewhere within your WordPress installation, I saved mine under wp-content/php/p90/. The last step is easy, copy and paste the following code into wpmenu.php; you will need to change lines 4 to 7 with your database's information and you may need to update the table name as_options, the default being wp_options on line 23 & table name as_posts, the default being wp_posts, on line 33.
-
<?php
-
-
#Your Info
-
$db_host = 'localhost:8888';
-
$db_username = 'root';
-
$db_password = 'root';
-
$db_name = 'wpdb';
-
-
-
#Connect To Database
-
-
-
#XML Output
-
print "<?xml version=\"1.0\"?>\n";
-
print "<wpmenu>\n";
-
print "\t<page>\n";
-
print "\t\t<item>Home</item>\n";
-
-
-
#GET HOME
-
$url_query = 'SELECT option_value FROM as_options WHERE option_name="siteurl"';
-
}
-
-
print "\t</page>\n";
-
-
-
#GET PAGE(s)
-
$page_query = 'SELECT * FROM as_posts WHERE post_type="page" ORDER BY menu_order ASC';
-
print "\t<page>\n";
-
print "\t</page>\n";
-
}
-
-
print "</wpmenu>";
-
-
#Disconnect From Database
-
-
?>
If you go ahead and open wpmenu.php in your browser, you will see something like...
Home http://actionscript.marlonvalenzuela.net About http://actionscript.marlonvalenzuela.net/?page_id=47 Requests http://actionscript.marlonvalenzuela.net/?page_id=76
It doesn't look like XML but if you choose View Source, you will see...
-
<?xml version="1.0"?>
-
<wpmenu>
-
<page>
-
<item>Home</item>
-
<url>http://actionscript.marlonvalenzuela.net</url>
-
</page>
-
<page>
-
<item>About</item>
-
<url>http://actionscript.marlonvalenzuela.net/?page_id=47</url>
-
</page>
-
<page>
-
<item>Requests</item>
-
<url>http://actionscript.marlonvalenzuela.net/?page_id=76</url>
-
</page>
-
</wpmenu>
With the XML output ready, we can create a flash file that calls wpmenu.php and display our menu inside a flash movie.



