PEAR Articles

  Home arrow PEAR Articles arrow Page 4 - Creating the Main Pages of a PEAR CMS
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

  •  
     

    SEARCH CODEWALKERS

    TOOLS YOU CAN USE

    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.
    blog comments powered by Disqus

    PEAR ARTICLES ARTICLES

    - Installing PEAR
    - PEAR: an Introduction
    - Managing robots.txt using PHP: Generating Dy...
    - 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


    © 2003-2012 by Developer Shed. All rights reserved. DS Cluster 6 - Follow our Sitemap