Home arrow MySQL arrow Page 4 - Paginating Result Sets for a Search Engine Built with MySQL and PHP 5

Maintaining the value of a given search term across different web pages - MySQL

If you're a PHP developer looking for an approachable guide on how to build an expandable search engine with MySQL and PHP 5, then this series of articles might be quite useful to you. Welcome to the second installment of the series that began with "Building a Search Engine with MySQL and PHP 5." These tutorials will show you how to create a fully functional search application by using the capabilities provided by the MySQL/PHP 5 team.

TABLE OF CONTENTS:
  1. Paginating Result Sets for a Search Engine Built with MySQL and PHP 5
  2. Listing the full source code for the original search engine
  3. Adding pagination capabilities to the initial search engine
  4. Maintaining the value of a given search term across different web pages
By: Alejandro Gervasio
Rating: starstarstarstarstar / 4
August 01, 2007

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

As I expressed in the section that you just read, the last step that I'm going to take for the moment will consist of building a basic session handling class. This class will come in useful for maintaining the value of a given search string across the different web pages generated by the page links that you learned before.

With the session handling class, each time an user performs a search against one or more selected databases, the search terms will be kept when clicking on the page links. Quite simple, isn't it?

That being said, here is the signature of this brand new session handling class: 

class SessionHandler{
   public function __construct(){
     session_start();
   }
   public function setVariable($value='default',$varname='default'){
     $_SESSION[$varname]=$value;
   }
   public function getVariable($varname='default'){
     if(!$_SESSION[$varname]){
       return false;
     }
     return $_SESSION[$varname];
   }
   public function destroy(){
     session_start();
     session_unset();
     session_destroy();
   }
}

As you can see, the above session handler presents a few basic methods for registering and deregistering session variables, in addition to destroying a complete session. This class is the one that I'm going to use in conjunction with the others defined earlier to implement a fully functional searching application. However, the completion of this MySQL-driven search engine will be done in the last tutorial of the series.

Final thoughts

In this second article of the series I explained in detail how to add result pagination capabilities to the existing MySQL-based search engine by incorporating some basic methods into the "Result" class that was developed in the first tutorial. I also defined a brand new session handling class for maintaining the value of a given search string across different web pages.

Thus, the next logical step will consist of putting all these classes to work together, in this way completing the development of this expandable search application. Naturally, this will be done in the last part of the series, so you don't have any excuses to miss it!



 
 
>>> More MySQL Articles          >>> More By Alejandro Gervasio
 

blog comments powered by Disqus
   

MYSQL ARTICLES

- Oracle Unveils MySQL 5.6
- MySQL Vulnerabilities Threaten Databases
- MySQL Cloud Options Expand with Google Cloud...
- MySQL 5.6 Prepped to Handle Demanding Web Use
- ScaleBase Service Virtualizes MySQL Databases
- Oracle Unveils MySQL Conversion Tools
- Akiban Opens Database Software for MySQL Use...
- Oracle Fixes MySQL Bug
- MySQL Databases Vulnerable to Password Hack
- MySQL: Overview of the ALTER TABLE Statement
- MySQL: How to Use the GRANT Statement
- MySQL: Creating, Listing, and Removing Datab...
- MySQL: Create, Show, and Describe Database T...
- MySQL Data and Table Types
- McAfee Releases Audit Plugin for MySQL Users

Developer Shed Affiliates

 



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

Dev Shed Tutorial Topics: