使用pg_query_params数组占位符搜索多个列

I pass two different values into the file, one which the user entered and the other which is selected from a predefined set of values in a drop down menu, which is the one i'm having trouble with.

When using a single placeholder for the query it works,for example:

$result = pg_query_params($con, "SELECT * FROM chemsub WHERE name like $1", array("%".$_REQUEST['term']."%"));

I want to alter the query so the user can change which column they are searching i can't seem to get it to work, here is what i have

$result = pg_query_params($con, "SELECT * FROM chemsub WHERE $1 like $2", array($_REQUEST['dropdown'],"%".$_REQUEST['term']."%"));

I know the correct value is being passed into the file with the correct spelling matching a column name in the database but for some reason it returns no rows.

Any help would be much appreciated.

You can't have params in place of identifiers. If you want to have a dynamic column being queried again you can either prepare the query text in php or have the sql look like ($1 = 'foo' AND foo LIKE $2) OR ($1 = 'bar' ANd bar LIKE $2.`