| | |||||||
| |||||||
| |||||||
|
|
|
|
|
|
|
Building an Authors Page for a PEAR CMS(Page 1 of 4 ) Welcome to the ninth part of a 12-part series on building a content management system with PEAR. In this part, we will look at the authors page. This page provides the user with a list of authors. This lets them choose to read articles written by a particular author. We will also begin discussing the authart page. The script for this page is activated when the user clicks on the Authors link that is displayed in the navigation panel. The code for the page looks like this: <?php session_start(); if(!isset($_SESSION['author_name'])){ //redirect to login page header("location:login.php"); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/main.dwt.php" codeOutsideHTMLIsLocked="false" --> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <!-- InstanceBeginEditable name="doctitle" --> <title>Untitled Document</title> <!-- InstanceEndEditable --> <!-- InstanceBeginEditable name="head" --> <!-- InstanceEndEditable --> <link href="Templates/pear.css" rel="stylesheet" type="text/css" /> </head> <body> <table width="100%" border="0" class="bord"> <tr class="header1"> <td colspan="2"><div align="center">Content Management System </div></td> </tr> <tr> <td width="5%" valign="top"><!-- InstanceBeginEditable name="EditRegion4" --> <table width="100%" border="0" cellspacing="0" class="navbord"> <tr> <td colspan="2" bgcolor="#FFFFFF"> </td> </tr> <tr> <td colspan="2" bgcolor="#0066FF" class="section"><strong>Section</strong></td> </tr> <tr class="navbord"> <td class="nav"><a href="logout.php">Logout</a> </td> <td><img src="images/user.gif" width="16" height="16" alt="" /></td> </tr> <tr class="navbord"> <td colspan="2" class="nav"><a href="main.php">Home</a></td> </tr> <tr class="navbord"> <td colspan="2" class="nav"><a href="authors.php">Authors</a></td> </tr> <?php if($_SESSION['level']=="admin"){?> <tr class="navbord"> <td colspan="2" class="nav"><a href="admin/index.php">Admin</a></td> </tr> <?php }?> </table> <!-- InstanceEndEditable --></td> <td width="95%" valign="top"><!-- InstanceBeginEditable name="EditRegion3" --> <table width="100%" border="1"> <tr><td></td></tr> <?php include 'db.php'; include 'connx.php'; $sql = "SELECT * FROM authors"; $res = $db->query($sql); if($res){ while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) { ?>
<tr> <td class="auth"><a href="authart.php?aid=<?php print $row->aid?>" class="auth"><?php print $row->name?></a></td> </tr> <?php } }else{ ?>
<tr> <td colspan="2" class="maintxt"><p class="auth">No authors found</p></td> </tr> <?php } ?> </table> <!-- InstanceEndEditable --></td> </tr>
<tr class="copy"> <td colspan="2">©2008</td> </tr> </table> </body> <!-- InstanceEnd --></html> More PEAR Articles Articles |
| |
| |