Home arrow PHP arrow Page 5 - Building a Relational Content Management System in PHP/MySQL

Displaying the Articles - PHP

You may be familiar with relational databases, but what is a relational content management system? Read on to learn how to build this system, which helps you create a search engine friendly site fairly quickly.

TABLE OF CONTENTS:
  1. Building a Relational Content Management System in PHP/MySQL
  2. The Rewrite
  3. The Common Functions
  4. Managing Articles
  5. Displaying the Articles
By: Roger Stringer
Rating: starstarstarstarstar / 39
December 20, 2005

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Okay, so now we've reached the fun part, actually displaying the articles for people to read.

Create a file called "index.php":

<?
  include("common.php");
  $mode = isset($_REQUEST['mode']) ? $_REQUEST['mode'] : '';
  $seoname = isset($_REQUEST['seoname']) ? $_REQUEST
['seoname'] : '';
  if( !empty($seoname) ){
    $seoname = explode("-",$seoname);
    $seoname = end($seoname);
  }
?>
<table width=100%>
<tr>
  <td width=200>
<?
  $leftMenu = getPages('parent','0');
  foreach($leftMenu as $id=>$page){
    echo "<a href='{$page['seoname']}.html'>{$page['title']}
</a><br/>";
  }
?>
  </td>
  <td>
<?
  if( !empty($seoname) ){
    $page = getPage('seoname',$seoname);
  }else{
    $page = getPage('id','1');
  }
?>
    <h1><?=$page['title']?></h1>
    <p><?=nl2br($page['body'])?></p>
<?
  $kids = getPages('parent',$page['id']);
  if( count($kids) > 0 ){
    foreach($kids as $id=>$kid){
      echo "<a href='{$page['seoname']}-{$kid['seoname']}.html'>
{$kid['title']}</a><br/>";
      echo "<p>{$kid['summary']}</p>";
    }
  }
?>
  </td>
</tr>
</table>

Here, we look to see whether we've passed the $seoname variable, and if we have, we split it into an array and grab its last value. This lets us use that as the article id and display the current article. We can build on this system quite easily.

Conclusion

There we have it: a quick, easy to use Relational CMS.

This CMS can be built on pretty easily and quickly, but I wanted to get the basics down here first.



 
 
>>> More PHP Articles          >>> More By Roger Stringer
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: