Page 1 of 1

MySQL Search

Posted: Thu Nov 03, 2005 6:53 am
by mhouldridge
Hi,

I need to search all my colums within my software table using the search post;


Here is my query;

Code: Select all

$result = mysql_query("SELECT * FROM software WHERE $array LIKE '%$search%' ORDER BY id");

I created an array with my colum names however this is not working.

Does anybody know howto do this.

Posted: Thu Nov 03, 2005 7:07 am
by Jenk
you cannot echo an array, you can only echo strings, floats or integers. :)

In other words, you need to take your column headings out of the array and insert them into the query string :)

Posted: Thu Nov 03, 2005 7:12 am
by mhouldridge
my column headings are id, publisher, name and version;

I tried this, however it did not work;

$result = mysql_query("SELECT * FROM software WHERE 'id', 'publisher', 'name', 'version' LIKE '%$search%' ORDER BY id");

Posted: Thu Nov 03, 2005 7:15 am
by Jenk
WHERE `id` LIKE '%{$search}%' OR `publisher` LIKE '%{$search}%' etc. :)

Posted: Thu Nov 03, 2005 7:38 am
by mhouldridge
Ok...

But if I want to check all of these values with this query?