MySQL
  Home arrow MySQL arrow Page 4 - Paginating Result Sets for a Search En...
Dev Shed Forums 
Administration  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
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? 
MYSQL

Paginating Result Sets for a Search Engine Built with MySQL and PHP 5
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 3
    2007-08-01

    Table of Contents:
  • Paginating Result Sets for a Search Engine Built with MySQL and PHP 5
  • Listing the full source code for the original search engine
  • Adding pagination capabilities to the initial search engine
  • Maintaining the value of a given search term across different web pages

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

    TestComplete™ automates software testing for a fraction of what the big guys charge. Easy functional and load testing for all Windows, .NET, Java and Web apps. Download a free trial now.

    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
    (Page 4 of 4 )

    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!


    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.

       · In this second tutorial of the series, the initial search engine built in the...
       · hi i was running through the tutorial and i am getting Error performing query...
       · Thank you for commenting on my PHP article. Regarding your question, the search...
       · Nice article again Alejandro TYVM.With regard to any database errors make sure...
       · Hello Jon,Thank you for the kind words on my PHP article. What you point out...
     

       

    MYSQL ARTICLES

    - MySQL Table Prefix Changer Tool in PHP
    - Using the SIGNAL Statement for Error Handling
    - Error Handling Examples
    - Error Handling
    - Completing a Search Engine with MySQL and PH...
    - Paginating Result Sets for a Search Engine B...
    - Building a Search Engine with MySQL and PHP 5
    - Using Boolean Operators for Full Text and Bo...
    - PHP, MySQL and the PEAR Database
    - Working with PHP and MySQL
    - Getting PHP to Talk to MySQL
    - Creating an RSS Reader: the Reader
    - MySQL Security Overview
    - Creating the Admin Script for a PHP/MySQL Bl...
    - Creating the Blog Script for a PHP/MySQL Blo...




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway