Jump to content

[SOLVED] Searching a database


ecopetition

Recommended Posts

Hello,

 

I'm trying to search a database with table X using the following query, where $search_query is the inputted search string and Y and Z are two columns.

 

$sql = "SELECT *
FROM X
WHERE Y
LIKE ($search_query)
ORDER BY Z DESC";

 

This code works fine, but returns a result only when Y is EQUAL to the search query, rather than when Y only just includes the search query somewhere.

 

Does anyone have a clue what's wrong or what I can do you fix this?

 

Thanks, Peter

Link to comment
https://forums.phpfreaks.com/topic/125957-solved-searching-a-database/
Share on other sites

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.