HomePHP Page 4 - Handling Entries for a Blogger Built with PHP
Creating the displayUpdateForm() method - PHP
Are you searching for an accessible guide on how to create a blog application with PHP 5? Then this set of articles might be what you’ve been looking for! Welcome to the second part of the series “Building a Blogger with PHP.” In three parts, this series demonstrates in a few easy steps how to build a classic blog application in PHP 5 by following an object-oriented approach.
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:
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!