...

View Full Version : get content of each .HTML files & put it in database



ungovernable
02-19-2008, 08:37 AM
Hello,

I have a old site that is 100% plain html files. I'm looking to migrate the site to work with a php-built CMS. The problem is that i have thousands of articles in html format, and I don't want to add them all one-by-one through the admin section of my CMS. So the only solution for me is to find a code that would take the html codes inside each of my static html files, and create an entry in my database with the content found.

My site's structure is currently like this:

www.mysite.com/books/Name Of The Book.html


I have chosen JOOMLA for my CMS. Joomla stores its articles in a table called "jos_content"

the structure of "jos_content" for the imporant article infos is:
"id" = ID of the article, so we have to increase this by one for each new article
"title" = Title of the article. In my case i'd put here the filename of the .HTML since it is the title of my articles
"introtext" = text of the article. It should be the content inside of my HTML files

So basically i'd need a code that would look for these informations and create a new entry for each of the .HTML files found in my /books/ server. For the rest I can do it myself, but if someone can hook me up with a code that would do what I explained above it would greatly help me to have somewhere to start since i'm still a newbie with php!

StupidRalph
02-19-2008, 11:55 AM
Do you want the entire contents (everything in the <head> section, any embedded CSS, the <body> tag and everything inside) of the .html file in the "introtext" field? Or do you want to put a certain part of each html?

If you want the whole thing inside..use file_get_contents() (http://www.php.net/file-get-contents). and then just run a query.

If you want certain sections in certain spots you'll need to parse the file to pull out what you want. But we'd need to know what the file looks like and what you want to go where in order to help you.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum