query ("SELECT productURL FROM products WHERE (upper(name) LIKE '%".$query."%')"); $totalResults = mysqli_num_rows ($sql); if ($totalResults == 1) { // This is the URL to the product specific page $theSQL = mysqli_fetch_array ($sql); $productURL = $theSQL['productURL']; } else { // Redirect to generic homepage if no results are found $productURL = "http://example.com"; } // Use this header function for quick redirect. You may alternatively use JavaScript header ("location: ".$productURL); ?>