Jump to content

[SOLVED] Article System


robgolding63

Recommended Posts

Hi,

I have just setup a new site for articles relating to windows server, networking and the like. I am writing the articles myself, and at present the HTML source for them is stored in a MySQL database. It's nice and fast, but a bit hard to edit the articles once they are published. Is there a better way to do this?

 

Also, my article edit form uses a textarea box for the HTML source, but if I have an article with a textarea in it, the browser ends the <textarea> that is used for editing the article, and prints out the rest of the article onto the page! If I could fix this problem, then I could live with keeping the articles in the database, but I just cant think of a solution!

 

I thought about maybe storing just HTML files, and having a PHP file check them every so often, loading the contents into the database for fast access from the site, but also easy editing by myself, just using Dreamweaver.

 

Hope someone can help!

 

Rob

Link to comment
Share on other sites

The problem with the htmlentities this is, I actually need it to still be in parseable HTML format, so that when it is fetched from the database, it is parsed properly.

 

In reply to shaun, that sounds like a good plan! If I store the details about the article in the database, with the name of a HTML file that contains the content, I can just include that - hows that for a plan?

 

Thanks guys,

 

Rob

Link to comment
Share on other sites

OK it's all working already! I just copied all the sources from the DB into HTML files, and changed the articles class to include it instead. Also, I made my own getcontents() funtion, so that if the file doesn't exist for some reason, I dont get an ugly error!

 

If you're interested I can post the code. The site is www.maxms.net - I only have 7 articles so far, so it was quick to transfer all the sources over. This'll make it much easier to edit them.

 

Thanks!

 

Rob

Link to comment
Share on other sites

I have all this working nicely, and I should be all sured-up against SQL-injection, but I wanted to ask about performance.

 

When I print a list of articles, in a category for example, the PHP has to get the first 100 characters from each HTML file. Is this a big perfomance hit? I can post the code if it would help, but basically it gets the contents of each file, then uses substr() to get the first 100 characters. It has to do this for every article being printed out in the list, so it's like a summary for each one.

 

Thanks,

 

Rob

Link to comment
Share on other sites

Any ideas? I thought about having a PHP file load the first 100 characters into a summary field in the DB, and checking the file every so often to see if it has changed.

 

The only problem I would have is how to get a PHP file to run on a schedule, on a windows server (can't do a CRON job).

 

Thanks,

 

Rob

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.