PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
mhouldridge
Forum Contributor
Posts: 267 Joined: Wed Jan 26, 2005 5:13 am
Post
by mhouldridge » Thu Nov 03, 2005 6:53 am
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.
Jenk
DevNet Master
Posts: 3587 Joined: Mon Sep 19, 2005 6:24 am
Location: London
Post
by Jenk » Thu Nov 03, 2005 7:07 am
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
mhouldridge
Forum Contributor
Posts: 267 Joined: Wed Jan 26, 2005 5:13 am
Post
by mhouldridge » Thu Nov 03, 2005 7:12 am
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");
Jenk
DevNet Master
Posts: 3587 Joined: Mon Sep 19, 2005 6:24 am
Location: London
Post
by Jenk » Thu Nov 03, 2005 7:15 am
WHERE `id` LIKE '%{$search}%' OR `publisher` LIKE '%{$search}%' etc.
mhouldridge
Forum Contributor
Posts: 267 Joined: Wed Jan 26, 2005 5:13 am
Post
by mhouldridge » Thu Nov 03, 2005 7:38 am
Ok...
But if I want to check all of these values with this query?