. -------------------------------------------------------- Product Name QueryCatcher Product URL http://www.jasonclark.info/files.php Product Description A PHP/MySQL search term recorder module - collect queries logged into system, presents terms as browseable links Latest Version 1.0 Release Date 2008/06/16 Author's Name Jason Clark Author's Email jaclark@montana.edu Author's URL http://jasonclark.info License GNU's Public License (GPL) -------------------------------------------------------- The code from this application is also available in the Code4Lib Journal (http://journal.code4lib.org). The article that explains the "QueryCatcher" application is titled: "Making Patron Data Work Harder: User Search Terms as Access Points?" It can be retrieved at http://journal.code4lib.org/articles/78. */ //purpose: This code searches the database for the user specified search terms and logs the search terms to a database table. Then the results are displayed in groups of 15 to the user. //note: you will need to create your own database, user login, and password to have data to query - see the querycatcher.sql file in package for an example //note: all unique functions are stored within this file at the end of PHP script //pass db name, login data and connection directions mysql_pconnect("YOUR-DB-HOST","YOUR-DB-USER","YOUR-DB-PASSWORD") or die ("Error: Unable to connect to the database."); mysql_select_db("YOUR-DB-NAME"); ?> Search Results View: QueryCatcher There is missing information in your request!'."\n"; echo '
'."\n"; echo '

Please enter a value(s) to search for.
'; echo '
Use the browser BACK button and enter the missing information.

'."\n"; } break; case 1: if($bKeyword) { $result = mysql_query("SELECT * FROM item WHERE item_status='a' AND MATCH (dc_title, dc_creator, dc_description, dc_contributor) AGAINST ('+$keyword*' IN BOOLEAN MODE)"); $num_rows = mysql_num_rows($result); if ($num_rows == 0) { noMatches(); exit; } else { //log search term query, trim whitespace and store in "log" table of database $logQuery = @mysql_query("INSERT INTO log SET query_data='".trim($keyword)."', query_results='".$num_rows."', query_referrer='".$_SERVER['HTTP_REFERER']."'"); if (!$logQuery) { die('

Error adding query to log: ' . mysql_error() . '

'); } echo '

Your search for Keyword '.stripslashes($keyword).' resulted in '.$num_rows.' match(es).

'."\n"; } } break; }//end switch ?> '."\n"; //this section of code in the for statement displays all the information about the matching item while ($row = mysql_fetch_object($result)) { $id = $row->item_id; $title = stripslashes(html_entity_decode($row->dc_title)); $creator = stripslashes(html_entity_decode($row->dc_creator)); $description = stripslashes(html_entity_decode(substr($row->dc_description,0,400))); $dateIssued = $row->dc_date; $identifier = $row->dc_identifier; $discipline = stripslashes(html_entity_decode($row->dc_degreeDiscipline)); //code below displays the info to the user echo '
'."\n"; echo '
'.$title.'
'."\n"; echo '
Author: '.$creator.'
'."\n"; echo '
Date: '.$dateIssued.'
'."\n"; echo '
Program: '.$discipline.'
'."\n"; echo '
Abstract: '.$description.'...
'."\n"; echo '
Download File | View full details
'."\n"; echo '
'."\n"; echo '
'."\n"; }//end while() }//end if() ?> Your search contains invalid characters'."\n"; echo '
'."\n"; echo '

The Keyword search string '.$localKeyword.' contains invalid character(s)!!

Please use the browser BACK button and fix the error. Then resubmit your request.

'."\n"; return false; } } return true; }//end validation() //function displays a message to user if search resulted in no matching items. function noMatches() { echo '

Your search did not match any documents.

'."\n"; echo ''."\n"; echo '

Return to Search Form: QueryCatcher

'."\n"; }//end noMatches() ?>