Completing a Search Engine with MySQL and PHP 5 - Defining a simple web page generating class (
Page 3 of 4 )
As I stated in the prior section, the last task required to complete the development of this search application consists of building a simple yet effective web page generating class. This class will be responsible for creating the web documents required to display the results returned by a specified search query.
Of course, the definition of this brand new PHP class is entirely optional in this case, since the respective database results can be also shown by using a procedural approach instead of the object-oriented one that I'm explaining here. Nevertheless, I'd like to show you the signature for this class, regardless of the method that you may want to use for displaying the search results.
Given that, here's how this web page generating class looks:
<?php
class WebPage{
private $title;
public function __construct($title='MySQL-based Search
Engine'){
$this->title=$title;
}
public function displayHeader(){
return '<html><head><title>'.$this->title.'</title><link
href="default.css" rel="stylesheet" type="text/css" /></head>';
}
public function displayBody($content){
return '<body>'.$content.'</body>';
}
public function displayFooter(){
return '</html>';
}
}
?>
Quite simple, right? As you can see, the signature for the above "WebPage" class doesn't bear too much discussion. It performs a few simple tasks, such as building the header, body and footer sections of a typical web document. Therefore, assuming that you won't have major problems understanding the way that this class works, it's time to move forward and develop a hands-on example, where you'll be able to see how this MySQL-driven search engine does its business.
To learn how this practical example will be created, please click on the link below and keep reading.
| | Discuss Completing a Search Engine with MySQL and PHP 5 | | | | | | | Over the course of this final tutorial of the series, this MySQL/PHP 5 - based... | | | | | | It's a decent simple search engine, but that's all really. It gets tougher when you... | | | | | | Thank you for commenting on my PHP article. You’re correct regarding the simplicity... | | | | | | Getting a grasp on classes in php is difficult for some, like myself, but your... | | | | | | Thank you for the kind comments on my PHP article, and it's always good to know it's... | | | | | | Hi,
Thanks for the detailed tutorial. I began with confidence but I have... | | | | | | Thank you for the comments on my PHP article. Now, concerning your question, the... | | | | | | Hi Alejandro,
Thank you for taking your time to reply. I read your entire... | | | | | | Hi JSP,Thanks again for posting here. Now that you've created a "processform.php"... | | | | | | Thanks Alejandro,
That helps... WOW I wouldn't have guessed that, since I am no... | | | | | | Hi JSP,
Glad to know the search engine is working for you. Thanks again for the... | | | | | | Hi,
I am enjoying working through some of your tutorials am really pretty new to... | | | | | | Hi Joe,
Thanks for the comments on my PHP article. In fact, that’s not a bug of... | | | | | | Great Coding. How to solve the go back "bug"
In the form.htm, add a hidden input... | | | | | | Thanks for the comments on my PHP article and for the contributions to the search... | | | | | | Dear Alejandro Gervasio,
I am a new learner of PHP and MySQL i will be... | | | | | | Dear Alejandro Gervasio
I have read your artical care fully and copy past the... | | | | | | Hi Sayed,,
Thanks for the comments on my PHP article. I took a look at your code... | | | | | | Hi again Sayed,
Thanks for your interest on my PHP article, and I really... | | | | | | Dear Sir,
I copy and past the code for webpage.php class from your... | | | | | | Hey Sayek, are you getting a 500 internal server error? Then, you should check the... | | | | | | Hi Alejandro.
Nice Tutorial!
Can you tell me where the session data is to... | | | | | | Hey Efe,
Thanks for the kind words. I’m not sure to understand entirely your... | | | | | | >>> Post your comment now! | | | | | |
|
 |
|