Forum Moderators: coopster
The question is: should we use database and php instead of html? Since we have so many pages, I found it was a little bit difficult to maintain because a lot of products are included in more than one categories and each category has 5-9 pages. But if I use PHP and MYSQL, the pagerank of most of our pages will be 0 and some of them won't be indexed by search engines. I am thinking maybe we should use html files and PHP files at the same time. I will keep some important html pages and others will be driven from database. Is this a good idea? Or it will make the website dirty? Thanks for your input.
With HTML you can get a program that finds and replaces code in all files of a type and in a folder (with a subfolder option). This however is overkill for merely making changes.
PHP is intended to make serverside sharing of information between two or more documents much easier to achieve. Typically this point is ~NOT~ explained on ANY PHP tutorials and they have a habbit of fooling around with crap that is useless.
Let me explain my site's current PHP setup...
I effectively have a few thousand pages which share the same code, menus, etc. With PHP includes I can for example change the doctype almost instantly after I change my includes file and upload it via FTP. Then once that change is made it will effectively replace the prior doctype on all pages loaded.
Here is an example of the includes.php file...
First you set a string which can for example contain HTML...
<?php {
$dtd = '<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
';
?>
<?php tells the server this file is PHP ...?> closes the PHP. You can open and close PHP multiple times and inside of html.
$dtd = ''; is setting the HTML as a value for the $dtd variable.
Now inside my HTML documents you'll see the following on the top two lines...
<?php include("includes.php"); print $dtd;?>
<title>my title</title>
Assumming the includes.php (you can use any filename) file is in the same folder, a server (with PHP installed) will include that PHP from that file including any variables.
print $dtd will simply put whatever is assigned to the dtd variable in to the document.
Since PHP is serverside... this puts our HTML in to the file...the server sends the data...and the client recieves the following...
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>my title</title>
So the browser sees it as regular HTML. As long as you open and close your PHP tags correctly your PHP code will never reach the clientside.
//////////////////////////////////////
For my menus I need to change my menu code only once PER menu even though I have tens of thousands of menus from all the pages that my site has. But if I want to say change the JAB Creations link I need to change it once, upload my includes file, and then it instantly effects the entire site.
The ultimate benefit using this method of PHP is that you can instantly update your site via FTP using a single file for things in your HTML code that are universal. This saves you the time of having to manually upload every HTML file.
I ~THINK~ you can have PHP code in a file with an .html extension. Make sure that your server be it shared or owned is running PHP. The vast majority of servers do!
There are many other things you can do with PHP but I merely wanted to clearly inform you that YES PHP is the much better and easier alternative for updating content.
I use the same variables with few changes. For example here is what my menus look like serverside...
.....</head><body>
<?
print $table_author;
print $menu1;
print $menu2;
print $menu3;
print $menu4;
print $menu5c;
print $menu6;
print $menu7;
print $menu_5_01;
print $menu_5_02;
print $menu_5_03;
print $menu_5_04c;
print $menu_5_05;
print $menu_5_06;
print $menu_5_07;
print $menu_5_08;
print $menu_5_09;
print $menu_5_10;
print $menu_5_11;
print $menu_5_12;
print $menu_5_13;
print $menu_5_14;
print $menu_5_15;
print $menu_5_16;
print $div_body;
?><table........
The c at the end of menu 5_04 denotes that it is to send the code for a variable which contains html for a ~current~ menu (which in turn has a different class).
So when I put the PHP on the files individually I need to change the c per page inside the PHP. Once I do this ALL I have to do to change the menus if change the code once my includes and upload.
While you will ONE TIME need to upload all of your files when you get everything set via the PHP inside your HTML files...then you can update your includes.
If you use relative links...
<a href="../thisfile.html">link</a>
... and your site is on multiple levels of folders then you may want to create various includes.
<a href="../../thisfile.html">link</a>
All you do in the includes2.php is (in note pad) do a find and replace...
Find "../" and replace with "../../".
If your paths are absolute..
<a href="http://www.example.com/thisfile.html">....
then you will only need one includes file.
I hope this helps! You should be able to do everything I explain in all versions of PHP though most people run php 3 or 4 if i'm correct.
[edited by: jatar_k at 8:54 pm (utc) on July 2, 2005]
[edit reason] fixed quote tags [/edit]
If you have access to .htaccess you could rewrite the extensions from .php to make them still appear to be .html.
I don't have access to .htaccess on my server.
I am going to keep the important pages(home page, category home pages) to be .html and make products list pages driven from database (.php). I am not sure if search engines don't like this kind of websites (using both html and php files). I guess it's okay to have both technologies in one website, right? Thanks.
I don't have access to .htaccess on my server.
WebmasterWorld does not allow hosting recommendations or reviews, so we'll leave it there but honestly many places will give you a decent package for under $10 month and at $20/month the choices are beyond count. I don't know how much you're making per sale, but just ask yourself how many sales you would need to make to pay for any extra cost incurred and ask how many sales you think you might lose if pages get bumped from the index.
As for the other question - search engines won't care if you mix and match file extensions, but I normally try to avoid file extensions at all. So as a first preference, keep your old URLs. If you're going to give them up, make sure your new ones have no extensions at all.
That's fairly common b/c .htaccess causes a fair amount of server overhead, so some hosting services only want to turn it on for those who need it.
If you don't have htaccess you seriously need to get a different host! Without htaccess I could not stop image theift from my site with such class! ;-)
If you can't find the post look at the recent posts in my profile or wait long enough for me to post it! :-D