Im currently working on a script which allows me to enter new posts in a XML-file.
The XML ("config.xml") is read by a flash application to show videos. The XML-template is as follow, and is entered for each new movie I want to publish:
Code:
<item>
<title>$title</title> // from form ($_POST)
<description><![CDATA[$description]]></description> // short description of movie
<url>$URL</url> // URL to the moviefile (FLV)
<thumb>$thumb_url</thumb> // URL to thumbnail
</item>
I've created a short PHP-script which allows me to enter this details through a form. On the top and the bottom of the file there's a tag <movie> and </movie>, and using the fgets()-function with a "while", the script is searching for the first <movie>-line and place the new entery right below it.
Now, I really want to add the functionality to edit and delete posts, but I don't know how to do this. Maybe I can generate the XML with a database, but I started with PHP two weeks ago, so I'm still pretty n00b at this. I've read about SimpleXML in PHP5 as a easier way of doing this, but at this point this is a little too complicated to understand...
Summary: The point is to add, edit and delete items from the XML-file within a graphical interface.
That would give you an array containing all the items, which is pulled directly from the file. Then to delete or edit them, you would use a function that finds the nth instance of <item>...</item> where n is the key from the array.
It's not the cleanest way of doing it, but at least it doesn't require the information to be stored in the file AND a database. All the work is done right from the file.
-Steve
"Build a man a fire and he'll be warm for a day. Set a man on fire and he'll be warm for the rest of his life."
Bookmarks