I am in the process of upgrading my site, and i wasnt sure if I should use one index file, and have the contents from a mySQL db, or from include files?
any advice would be great,,
thanks in advance!!
| SitePoint Sponsor |
I am in the process of upgrading my site, and i wasnt sure if I should use one index file, and have the contents from a mySQL db, or from include files?
any advice would be great,,
thanks in advance!!





Common elements, like menus and such are usually included from include files, while other parts, like text, are pulled from a database.
www.nyanko.ws - My web-, software- and game development company.
www.mayaposch.com - My personal site and blog.
Why is it faster to have text from a db rather than a file include? or is that just because it is easier for admin reasions?





Storing data (text) in a db is faster and more reliable than storing it into a text file.
It's faster because you don't have to open a text file every time again.
I don't know the exact details, but I'm sure that there someone on this forum who wants to explain this more in depth to you![]()
www.nyanko.ws - My web-, software- and game development company.
www.mayaposch.com - My personal site and blog.



I think it is just a lot more convenient.
E.g. put your files in any folder and they will still work, whereas with includes you would need to either specify a full system path or a relative path.
In some ways it would be more reliable (because mysql automatically takes care of file locking) and easier to secure. Also it is fairly easy to take backups of your whole site.
Because MySQL doesn't have to find the location of the file on your server each time the page is called, it is a bit faster too. When there re lots of small requests to be made (e.g. while generating forum views in a bulletin board) there is a huge performance increase.
I dont really know too much about it either, but if you were very inquisitive, you could always download the source code and look at that![]()
Thanks for the advice, Im going to use mySQL which was my preferred option anyway, I just wanted to make sure i was making the right choice.
Should I display the contents by
eg.
$contents =
mysql_query("SELECT contents FROM pageContents WHERE page='home'");
$body_contents = mysql_fetch_array($contents);
<BODY>
<?PHP
echo "$body_contents";
?>
</BODY>
is this the best way to do it? or is there another way?
Thanks again.





errr gotta sort of disagree guys,
for content that is dynamic, ie the contents of this forum, a DB , a fast one anyway such as MySQL is ideal, but in general including text files for static content -headers,navigation,footers and static body content, etc is faster than using the DB and releases load off the db to serve the dynamic content.
If you have to rewrite the contents as in this forum then again the DB is the more efficient option, but for pages that only you update once in a while includes are gonna be faster.
Really it depends what your site does/is doing , but note that sites which make use of a total template/db content can have problems under heavy load, Vbulletin is a good example of this - not that I have ever noticed such here at sitepoint!
Hi
Lets assume that you are building a site using mysql and php.
These are the tools I trust and use. font.inc, header.inc, menu.inc are includes.
for dynamic content, i use php and create the page on the fly, calling includes when needed.
The Semi-Dynamic page is discussed in part 10 Advanced php of Kevin Yank's Building a Database-Driven Web Site Using PHP and MySQL. The tutorial may be found at: http://www.webmasterbase.com/article.php?aid=228&pid=0
(in my copy the information needed is on page 103)
The refernced section is written to reduce the stress on server time. If you have a page that is not changing all the time. For example is not user updated, then the Semi-Dynamic saves lots of server time. Esentially, you load a dynamic page and make it a static page and when requested, load the static page. Updating the page is also covered.
peace
Ed Shuck
www.noevalley.com
OK thanks everyone, I think i will go for includes now.
I feel like a tennis ball at the moment,, being thrown here and there!
but It makes allot more sense to use uncludes for my purpose, since the pages will be rarely updated..
once again thanks for all your support.
Bookmarks