topical media & game development 
  
 
 
 
 
  
    
    
  
 professional-sql-04-public-files-search.php / php
  <?php 
  // include shared code
  include '../lib/common.php';
  include '../lib/db.php';
  include '../lib/functions.php';
  
  // accept incoming search terms if the form has been submitted
  _GET['query']) && trim(words = explode_items(query = sprintf('SELECT TERM_VALUE FROM \%sSEARCH_STOP_WORD',
          DB_TBL_PREFIX);
      query, stop_words = array();
      while (result))
      {
          row['TERM_VALUE']] = true;
      }
      mysql_free_result(words_removed = array();
      foreach (index => stop_words[strtolower(words_removed[] = words[_SERVER['PHP_SELF']); ?>">
   <div>
    <input type="text" name="query" id="query" value="<?php
     echo (count(words)) : '';?>"/>
    <input type="submit" value="Search"/>
   </div>
  </form>
  <?php
  
  // begin processing query
  if (count(spell_error = false;
      ps = pspell_new('en');
      foreach (index => ps, s = pspell_suggest(word))
              {
                  if (strtolower(word))
                  {
                      // (ignore capitalization-related spelling errors)
                      suggest_words[s[0];
                  }
              }
          }
      }
  
      // formulate the search query using provided terms and submit it
      where = '';
      words as word)
      {
          index, index, index);
      
          index, 
              mysql_real_escape_string(strtolower(GLOBALS['DB']));
      }
      join . 'WHERE ' . query = substr(query) - 4);
      query, num_rows = mysql_num_rows(words)) . 
          '</b> yielded ' . num_rows != 1) ? 's' : '') . ':</p>';
  
      // show suggested query if a possible misspelling was found
      if (words as word)
          {
              if (isset(index]))
              {
                  index] = index]; 
              }
          }
          echo '<p>Possible misspelling.  Did you mean <a href="' . 
              htmlspecialchars(words))) . '">' . 
              htmlspecialchars(join(' ', row = mysql_fetch_assoc(row['DOCUMENT_URL']) . '">' .
              htmlspecialchars(row['DESCRIPTION']) . '<br/><i>' .
              htmlspecialchars(GLOBALS['TEMPLATE']['content'] = ob_get_clean(); 
  
  // display the page
  include '../templates/template-page.php';
  ?>
  
  
  
(C) Æliens 
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher. 
In case of other copyright issues, contact the author.