Jump to content

I think this is an easy question


mmcspadden

Recommended Posts

What I am trying to accomplish: Create a menu using PHP that pulls data from a central source for all the pages on my site so that I don't have to ctrl-v on all 60 some odd pages when i update a link. What I have tried: I have tried using a MYSQL table. I have tried to recreating a PAD file which has the concept that I am looking for, where all info is in an XML file and it gets parsed for the text info which can them be wrapped in html. I have also tried several other examples of parsing data from an XML file in other ways. My Problem: I could not figure out how to create, edit, or use the MYSQL table, decided to try to stick with XML file being parsed by PHP if possible. I can get the PHP scripts to work when accessing a PAD file from another domain but have been unable to get a modified one to work locally. It simply says cannot load PAD file. The other examples of parsing data from an XML file are such that they list all the information provided. I need something where I can pick and choose which info gets listed. Example 1 is of a working PAD filehttp://www.anvilsmithtech.com/test/pad/test.phpExample 2 is of a modified local PAD file that I tried and didn't workhttp://www.anvilsmithtech.com/test/pad/test1.phpExample 3 is one I got from a tutorial website but it lists all the items on the list and I cannot figure out how to list only some of them. http://www.anvilsmithtech.com/test/list/list.phpI'm sure it is something simple that I am doing wrong, but if anyone could help me figure it out that would be great. Matt

Link to comment
Share on other sites

it kinda depends on how dynamic the menu should be, if its just some links that get updated once in a while its probably the easiest just to save them in a file, and include that in the other files, either using include, require, fopen/fread of file_get_contentsyou can save it as xml, and use for example the simplexml_load_file functionyou also can do it with mysql, to do that id recommand installing phpMyAdmin, which is easy to create tables and adding and editing rows, then just use mysql_query('SELECT etc..') to get them in ure menu

Link to comment
Share on other sites

I figured out that much from scowering google and various forums :), I should have mentioned I'm fairly new to PHP. I don't understand all the posts that I have read on various websites that say use this function or that call thingee. I understand stuff much better if I have an example that I can see working then edit it till I understand how it works. Anyone have a working example that you wouldn't mind me taking and editing?The menu is not meant to be all that dynamic, the site is meant to be a list of downloadable programs and when the program gets updated I'd like to update one document with the new name and link rather than 60 documents. Thanks

Link to comment
Share on other sites

I think the easiest way would be to write the links in a file, and use the php function include("filename") to all the pages and just edit the file with all the links. I've never used include() to include files that write HTML, but logically it would work.

Link to comment
Share on other sites

For examples, you can look on the PHP site... follow the link posted by Wander.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...