This is some PHP search code with some mistake. $run gives nothing where $run = mysql_query($construct); It gives: Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\xampp\search\search2.php on line 39
No results found.

<?php

//get data
$button = $_GET['submit'];
$search = $_GET['search'];

if(!$button)
	echo "You didn't submit a keyword.";
else
{
	if (strlen($search)<=3)
		echo "Search term too short.";
	else
	{
		echo "You searched for <b>$search</b> <hr size='1'>";
		
		//connect to our database
	mysql_connect("localhost","root","");
	mysql_select_db("usertable");

		//explode our search term
		$search_exploded = explode(" ",$search);
	
			foreach($search_exploded as $search_each)
			{
				//construct query
				$x++;
				if ($x==1)
					$construct .= "keyword LIKE '%$search_each%'";
				else
					$construct .= "OR keywords LIKE '%$search_each%'";
			}
		
		
		$construct = "SELECT * FROM search WHERE '$construct'";
		$run = mysql_query($construct);
		echo $run;
		
		$foundnum = mysql_num_rows($run);
		
		if ($foundnum==0)
			echo "No results found.";
		else
		{
			echo "$foundnum results found!<p>";
		}

	}
}

?>

Try losing the the single quotes around $construct. Instead you want to prepend the SELECT statement right?

$construct = "SELECT * FROM search WHERE $construct";

Again it's not working

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.