PEAR Articles
  Home arrow PEAR Articles arrow Page 4 - Creating the Main Pages of a PEAR CMS
Codewalker Forums 
  Tutorials  
Database Articles  
Miscellaneous  
Navigation Usability  
PEAR Articles  
Programming Basics  
Server Administration  
XML Tutorials  
  Reviews  
Database Book Reviews  
Linux Book Reviews  
Miscellaneous Reviews  
PHP Book Reviews  
PHP Software Reviews  
Server Admin Reviews  
SQL Tool Reviews  
  Code Gallery  
Content Management Code  
Contest Code  
Counters Code  
Database Code  
Date Time Code  
Discussion Board Code  
Email Code  
File Manipulation Code  
GUI Code  
Link Farm Code  
Miscellaneous Code  
Search Code  
Site Navigation Code  
User Management Code  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Download TestComplete 
Forums Sitemap 
Weekly Newsletter 
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PEAR ARTICLES

Creating the Main Pages of a PEAR CMS
By: David Web
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2008-10-29

    Table of Contents:
  • Creating the Main Pages of a PEAR CMS
  • Code Explained
  • More Code
  • Run the Query

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Creating the Main Pages of a PEAR CMS - Run the Query


    (Page 4 of 4 )

    Once we’ve created the query, we now have to run it. DB uses MySQL equivalent (mysql_query()) of $db->query() to run the query. The result of this query is stored in a variable called $res:

    $res = $db->query($sql);



    We test to see if any records have been returned, and then call the while loop to retrieve the records:

    if($res){

    while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {

    ?>

    The code then builds rows and columns as appropriate to display the information. Each row in the table will display the title of the article and the name of the author who wrote the article. The title of the article provides a link to the view page that allows you to view an article in full:

    <tr>

    <td colspan="2" class="title"><a href="view.php?sid=<?php print $row->sid?>"


    class="title"><?php print $row->title."..."; ?></a></td>

    </tr>

    <tr>

    <td width="18%">&nbsp;</td>

    <td width="82%" class="auth">by:<?php print $row->name ?></td>

    </tr>

     The link in the title of the article has a query string attached to it. This query string will send a story ID or sid to the view page, which then uses that id to retrieve the appropriate story:

    <td colspan="2" class="title"><a href="view.php? sid=<?php print $row->sid?> "

    class="title"><?php print $row->title."..."; ?></a></td>

    If the query does not return any records, we write an appropriate error message:

    <?php

    }//end while

    }// no recs retrieved run else block

    else{

    ?>

     

    <tr>

    <td colspan="2" class="maintxt"><p>No records found</p></td>

    </tr>

    <?php } ?>

    </table>

    The table is then closed and the rest of the HTML is also closed to complete the HTML page:

    <!-- InstanceEndEditable --></td>

    </tr>

     

    <tr class="copy">

    <td colspan="2">&copy;2008</td>

    </tr>

    </table>

    </body>

    <!-- InstanceEnd --></html>

    In the next article we will delve more deeply into the page that allows us to view an article in full. Be sure to check back next week.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

     

    PEAR ARTICLES ARTICLES

    - Deleting Authors from a PEAR Content Managem...
    - PEAR CMS: Index and Delete Scripts
    - Listing Articles for a PEAR Content Manageme...
    - Building an Authors Page for a PEAR CMS
    - Building the View Details Page in a PEAR CMS
    - Creating the Main Pages of a PEAR CMS
    - Completing the Login Script for a PEAR CMS
    - User Authentication for a PEAR CMS
    - A PEAR CMS: Examining the Code
    - Building a Content Management System with PE...
    - Installing a PEAR Package
    - My PEAR: The Beginning
    - Using XML_RPC2 with PEAR
    - Using Web Service APIs (Amazon and Yahoo!) w...
    - Database Abstraction with MDB2 from PEAR





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    Stay green...Green IT