Jump to content

MySQL query to search multiple fields in one table


devan

Recommended Posts

I want to have a search product feature, but I would like members to be able to search multiple fields in one go i.e.  product_code, Product_name in one MySQL query.

 

The thing is, members have to be logged on, so the query must also only show results relating to that specific member, via the session[member_ID], my current query for listing products for that specific member is :

 

$sql = "SELECT productId, productCode, image, name, price, stock_level FROM product_inventory WHERE memberr_ID = '" . $_SESSION['SESS_mem_ID'] . ";

 

How would I change the above into a search query to search for productcode, productname and still only show results beloging to this member using the session data ?  :confused:

 

all help appreciated

It can't be this easy, I must have missed something. :shrug:

Your code:

$sql = "SELECT productCode, name FROM product_inventory WHERE memberr_ID = '" . $_SESSION['SESS_mem_ID'] . ";

 

You might have to change how this is displayed. Don't know, that code was not supplied. Give it a go.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.