Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 7th, 2012  |  syntax: None  |  size: 0.95 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. /*
  2.  * Split the string into an array, process each piece separately.
  3.  */
  4. foreach( $stringArray as $string ) {
  5.  
  6.     /*
  7.      * Handle street and apartment numbers using a LIKE, normally these will be
  8.      * under 4 characters
  9.      */
  10.     if( is_numeric($string) ) {
  11.  
  12.         $where .= " AND (
  13.                         FormattedAddress LIKE '%".$string."'
  14.                         OR FormattedAddress LIKE '".$string."%'
  15.                     )\n";
  16.  
  17.     // Most of the time we should match on string > 3, if not, use a like
  18.     } elseif( strlen($string) > 3) {
  19.         $where .= " AND MATCH(FormattedAddress) AGAINST (".r3a($string).")\n";
  20.     }
  21. }
  22.  
  23.  
  24. ----
  25.  
  26.  
  27. $query = "
  28.     SELECT
  29.         E.FormattedAddress,
  30.         E.Address,
  31.         E.ESIID,
  32.         E.City,
  33.         E.Zip
  34.     FROM
  35.     EnergySavings.ESIIDs E
  36.     WHERE
  37.         E.Zip = " . r3a($_REQUEST['Zip']) . "
  38.         {$where}
  39.     ORDER BY
  40.         E.FormattedAddress ASC
  41.     LIMIT 10