All pastes #178017 Raw Edit

Anonymous

public php v1 · immutable
#178017 ·published 2006-09-20 22:22 UTC
rendered paste body
if (isset($_REQUEST['SubmitSearch'])) { 		# Init SQL search filter. 	$SearchQuery = ""; 		# Which fields are we searching on? 	if (isset($_REQUEST['Search_Fields']) && ! empty($_REQUEST['Search_Terms'])) { 			// These are values from the drop-down box, a.k.a. <select> 		if ($_REQUEST['Search_Fields'] == "all") { 						$tmp_terms = mysql_real_escape_string($_REQUEST['Search_Terms']);						$terms = explode(" ", $tmp_terms);						foreach ($terms as $term)			{				$SearchQuery .= "dl_rtitle LIKE '%". $term ."%' OR ";  				$SearchQuery .= "dl_rauthor LIKE '%". $term ."%' OR ";  				$SearchQuery .= "dl_rsource LIKE '%". $term ."%' OR ";  				$SearchQuery .= "dl_rdate LIKE '%". $term ."%' OR ";   				$SearchQuery .= "dl_rurl LIKE '%". $term ."%' OR ";  				$SearchQuery .= "dl_rpublisher LIKE '%". $term ."%' OR ";  				$SearchQuery .= "dl_risbn LIKE '%". $term ."%' OR "; 			}					} elseif ($_REQUEST['Search_Fields'] == "title") { 			$SearchQuery .= "dl_rtitle LIKE '%". trim($_REQUEST['Search_Terms']) ."%' OR ";		} else if ($_REQUEST['Search_Fields'] == "author") { 			$SearchQuery .= "dl_rauthor LIKE '%". trim($_REQUEST['Search_Terms']) ."%' OR ";  		} else if ($_REQUEST['Search_Fields'] == "source") { 			$SearchQuery .= "dl_rsource LIKE '%". trim($_REQUEST['Search_Terms']) ."%' OR ";  		} else if ($_REQUEST['Search_Fields'] == "year") { 			$SearchQuery .= "dl_rdate LIKE '%". trim($_REQUEST['Search_Terms']) ."%' OR ";  		} else if ($_REQUEST['Search_Fields'] == "url") { 			$SearchQuery .= "dl_rurl LIKE '%". trim($_REQUEST['Search_Terms']) ."%' OR ";  		} else if ($_REQUEST['Search_Fields'] == "publisher") { 			$SearchQuery .= "dl_rpublisher LIKE '%". trim($_REQUEST['Search_Terms']) ."%' OR ";  		} else if ($_REQUEST['Search_Fields'] == "isbn") { 			$SearchQuery .= "dl_risbn LIKE '%". trim($_REQUEST['Search_Terms']) ."%' OR ";  		} 				$SearchQuery = "(". substr($SearchQuery, 0, strlen($SearchQuery) - 3) .")"; 						// These are values from the radio buttons. 		if (isset($_REQUEST['Search_by_Type'])) { 							$SearchQueryType="";						if ($_REQUEST['Search_by_Type'] == "documents") { 				foreach (array("doc", "txt", "pdf") as $type) { 					$SearchQueryType .= " dl_rformat = '". $type ."' OR ";  				} 			} else if ($_REQUEST['Search_by_Type'] == "publications") { 				foreach (array("doc", "txt", "pdf", "rtf", "ppt") as $type) {					$SearchQueryType .= " dl_rformat = '". $type ."' OR ";  									}						} else if ($_REQUEST['Search_by_Type'] == "images") { 				foreach (array("jpg", "gif") as $type) {					$SearchQueryType .= " dl_rformat = '". $type ."' OR ";				}			} else if ($_REQUEST['Search_by_Type'] == "video") { 				foreach (array("mpg" , "avi", "mov", "mpeg") as $type) {					$SearchQueryType .= " dl_rformat = '". $type ."' OR ";				}			} else if ($_REQUEST['Search_by_Type'] == "audio") { 				foreach (array("mp3") as $type) {					$SearchQueryType .= " dl_rformat = '". $type ."' OR ";				}			} 						$SearchQueryType = substr($SearchQueryType, 0, strlen($SearchQueryType) - 4);			$SearchQuery = $SearchQuery . " AND (" . $SearchQueryType . ")";							} }