All pastes #249493 Raw Edit

StyleZed

public text v1 · immutable
#249493 ·published 2006-11-15 20:55 UTC
rendered paste body
// I have a search function... users are able to enter keywords and select a CITY from a  drop down... the search function works fine.. 
// but it doesn't return ONLY the matching results from the CITY - ie: if i want to search "pigs" in "los angeles" - the current query (below)
// returns all the pigs in all the cities... i want it to JUST return any results with my keyword in the city selected. city has it's OWN field in each $table

function testQuery( $table, $city, $word_array, $num_words )
		{
			if( $num_words != 0 )
			{
				$sql = "SELECT * FROM `$table` WHERE MATCH ( `name`, `street`, `owner`, `description`)
					AGAINST ('";
					
				for( $i = 0; $i < $num_words; $i++ )
				{
					$sql .= $word_array[ $i ]."* ";
				}
				$sql .= "' IN BOOLEAN MODE );";
				return mysql_query( $sql );
			}
			$sql = "SELECT * FROM `$table`;";
			return mysql_query( $sql );
		}