Call us Toll-Free:
Email us


Easy Dynamic Pages

Code Wizard, 12-30-2006

Dynamic, search-engine friendly pages using PHP and .htaccess, that look more like directories than PHP pages.

This contains 2 files, usage is described below:

------- File named: .htaccess
ForceType application/x-httpd-php3

------- File named: site (no extension)
$dbserver = "localhost";
$dbuser = "mysqlusername";
$dbpass = "mysqlpassword";
$database = "yourdatabase";


$product = $url_array[count($url_array)-1];

print "<b>DEBUG</b>: product is $product<br><br>

$result = mysql_query("select * from content where content_page = '$product'");
$row = mysql_fetch_array($result);

echo "<b>Title is</b> $row[content_title]<br>
echo "<b>Summary is</b> $row[content_summary]<br>
echo "<b>Added on</b> $row[content_created]<br>
echo "<b>Edited on</b> $row[content_edited]<br>
echo "<b>Body</b>: $row[content_body]<br>
echo "<b>Created by</b>: $row[content_creator]<br>
echo "<b>Parent</b>: $row[content_parent]<br>

$result = mysql_query("select content_summary,content_title,content_page from content where content_parent = '$row[content_page]'");

while ($row = mysql_fetch_array($result)) {
?>* <a href="site/<? echo $row[content_page]; ?>" onmouseover="window.status='<? echo $row[content_summary]; ?>';return true
" onmouseout="window.status='<? echo $pagename; ?>';return true"><? echo $row[content_title]; ?></a><br><?


------- Database SCHEMA
CREATE TABLE content (
content_page varchar(15) NOT NULL,
content_summary varchar(200) NOT NULL,
content_body blob NOT NULL,
content_creator int(5) DEFAULT '0' NOT NULL,
content_created datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
content_edited datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
content_title varchar(20) NOT NULL,
content_parent varchar(15) DEFAULT 'site',
PRIMARY KEY (content_page)

------- Usage

Firstly, insert data into the database. Top level (front page) should have
content_page set to 'site', with its subpages having the content_parent of
'site'. Call the page like: http://www.yourdomain/location/of/site to view
front page, or site/services to view page called 'services', etc. If you
combine this with Philip Olsons templates tutorial
( and you can easily create
dynamic, search-engine friendly pages.

Basically, 'site' is a PHP script. Calling it like site/services is the
same as calling a normal script as site.php?page=services. I have just
removed the extension (and turned it into PHP using .htaccess). This
should make it safe for searchengines, which don't often like pages
such as site.php?page=services.

This obviously needs lots of work, but if you need any help just post
in the EvilWalrus forums ( and I will help you!

------- Update: 21 July 2000
It could be very handy to add a 'page rendering counter' to the bottom of these pages, just for fun. Could also help pinpoint some errors/bad coding. Look at for more info.
Enjoyed this post?

Subscribe Now to receive new posts via Email as soon as they come out.

Post your comments

Note: No link spamming! If your message contains link/s, it will NOT be published on the site before manually approved by one of our moderators.

About Us  |  Contact us  |  Privacy Policy  |  Terms & Conditions