Home Inventory – how to include the columns descr, location and binnum in searching ?

A1WEBSITEPRO QuestionsCategory: QuestionsHome Inventory – how to include the columns descr, location and binnum in searching ?
Morten Nordby asked 1 year ago

I want to edit the file search.php so the search will cover the columns descr, location and binnum
I tried to edit the file and change the query, but discovered that when i did that the search results also included results from other users than the user currently logged in.

Very strange, and not what i intended so i changed back to the original search.php file on my serverinstallation: https://inventorylist.no
Could you check why that happened?

Morten

Only cool people share!

Home Inventory – how to include the columns descr, location and binnum in searching ? was last modified: April 13th, 2023 by Morten Nordby
Maximus Mccullough Staff replied 1 year ago

Let me know if that works for you and paste the whole file to me if it doesn’t.

1 Answers
Maximus Mccullough Staff answered 1 year ago

It would help if you give me the entire search.php code below. However, I would think that it is because of your query. Look at this code below. 

$query = "SELECT * FROM merch WHERE user='$uid' AND lower(nameMerch) LIKE '%$srh%' ORDER BY id ASC"; 

Now if I wanted to use the descr instead of nameMerch I would write it like this. 

$query = "SELECT * FROM merch WHERE user='$uid' AND descr LIKE '%$srh%' ORDER BY id ASC"; 

If I wanted to include both the nameMerch and descr I would writ it like this.

$query = "SELECT * FROM merch WHERE user='$uid' AND lower(nameMerch) LIKE '%$srh%' OR descr LIKE '%$srh%' ORDER BY id ASC"; 

Give that a try and let me know what it does for you

Only cool people share!

Answer for Home Inventory – how to include the columns descr, location and binnum in searching ? was last modified: April 13th, 2023 by Maximus Mccullough