PHPMYSQL - How do you perform a double SELECT query or check against multiple fields?

Does anyone know how this can be achieved? What i want is from a search page that has multiple search areas such as name / description / functions and be able to type multiple search queries in to a form and it narrow it down in mysql query.

My initial thought was something along these lines:

$query = mysql_query("SELECT * FROM `products` WHERE `name` LIKE '%$s1%' AND SELECT * FROM `products` WHERE `functions` LIKE '%$s3%'");

but that returns the following error:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /----/--------/------_----/------/getdatatest.php on line 110

Much help appreciated!

$query = mysql_query("SELECT * FROM `products` WHERE `name` LIKE '%$s1%' AND  `functions` LIKE '%$s3%'");
$query = mysql_query("SELECT * FROM `products` WHERE `name` LIKE '%$s1%' AND  `functions` LIKE '%$s3%'");

I tried this (Thanks BTW) and it didn't return the result it should have. Not sure if that query type works, I read somewhere on the Internet that it may involve JOIN or GROUP something, i personally have never heard of them :D

Replace AND with OR

if(($name!="")&(isset($name))&($name<>"select")) 
		{
			$condition=$condition."namelike '%$name%' and ";
		}
		if(($function!="")&(isset($vptype))ype<>"select")) {
			$condition=$condition."function like '%$function%' and ";
		}
if(($description!="")&(isset($description))ype<>"select")) {
			$condition=$condition."description like '%$description%' and ";
		}
		$condition=substr($condition,0,-4);

mysql_query("select * from tablename where (".$condition.")");

try like this. it will help you.

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.