PHP
  Home arrow PHP arrow Page 4 - Handling Entries for a Blogger Built with PHP
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
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? 
Google.com  
PHP

Handling Entries for a Blogger Built with PHP
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 3
    2006-11-28


    Table of Contents:
  • Handling Entries for a Blogger Built with PHP
  • Defining the displayBlogs() method
  • Defining the displayInsertForm() method
  • Creating the displayUpdateForm() method
  • Defining the displayHeader() and displayFooter() methods

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log 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


    Handling Entries for a Blogger Built with PHP - Creating the displayUpdateForm() method
    ( Page 4 of 5 )

    Following a similar approach to the one that I used for creating the insertion form that you learned about in the previous section, it's possible to define another important method that belongs to the "BlogProcessor" class. This one displays the required online form for updating a specific blog entry.

    This being said, the signature for this broadband new method, denominated "displayUdpateForm()" is the following:

    // display update form
    private function displayUpdateForm(){
                $id=$this->blogData['id'];
                $result=$this->mysql->query("SELECT * FROM blogs
    WHERE id='$id'");
                if($result->countRows()>0){
                            $row=$result->fetchRow();
    $output=<<<EOD
    <div class="dataform">
    <h2>Update Blog</h2>
    <form action="$_SERVER[PHP_SELF]" method="post" id="updateform">
    <p>Title:</p><p><input type="text" name="title" value="$row
    [title]" class="datafield" /></p>
    <p>Author:</p><p><input type="text" name="author" value="$row
    [author]" class="datafield" /></p>
    <p>Update your content below</p><p><textarea name="content">$row
    [content]</textarea></p>
    <p><input type="submit" name="updateblog" value="Update
    Blog" /></p>
    <input type="hidden" value="$id" name="id" />
    </form>
    </div>
    EOD;
                return $output;
                }
    } 

    As you'll certainly appreciate, the definition of the new method is closely similar to "displayInsertForm()", which was covered in the section you just read. This new method simply displays the corresponding update web form where all its boxes has been previously populated with the data that corresponds to the entry being updated (hence the execution of the SELECT statement in the first lines of code).

    With reference to the prior method in particular, the only thing worth noticing is the inclusion of a hidden box to store the respective ID of the blog entry being updated. Quite simple, isn't it?

    All right, at this stage you hopefully grasped the logic that stands behind the "BlogProcessor" class, and you understand how it displays the complete list of blogs and shows the pair of web forms necessary for inserting new blogs and updating previous ones. Thus, the next step involved in the development of this extensible blog application rests on creating three additional methods. These will be responsible for displaying programmatically the different sections that compose the main web page of the blogger, that is the header, the primary area and finally the footer.

    To learn how these useful methods will be created, be a bit more patient and read the following section. We're almost finished!



     
     
    >>> More PHP Articles          >>> More By Alejandro Gervasio
     

       

    PHP ARTICLES

    - Implementing Factory Methods in PHP 5
    - Merging a File Split for FTP Upload using PHP
    - Getting Data from Yahoo Site Explorer Inboun...
    - Method Chaining: Adding More Selecting Metho...
    - How to Split a File During an FTP Upload Usi...
    - Expanding a Custom CodeIgniter Library with ...
    - Using the Yahoo Site Explorer Inbound Links ...
    - Building a CodeIgniter Custom Library with M...
    - Building an E-mini Trading System Using PHP ...
    - Completing the MySQL Class with Method Chain...
    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...
    - Mastering WHILE Loops for PHP and MySQL





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek