I want to be able to search through a MySQL table using values from a search string, from the url and display the results as an XML output.
I think I have got the formatting and declaring the variables from the search string down.
The issue I have is searching the entire table, I've looked over SO for previous answers, and they all seem to have to declare each column in the table to search through.
So for example my database layout is as follows:
**filesindex**
-filename
-creation
-length
-wall
-playlocation
First of all would the following be appropriate:
$query = "SELECT * FROM filesindex WHERE filename LIKE '".$searchterm."%'
UNION
SELECT * FROM filesindex WHERE creation LIKE '".$searchterm."%'
UNION
SELECT * FROM filesindex WHERE length LIKE '".$searchterm."%'
UNION
SELECT * FROM filesindex WHERE wall LIKE '".$searchterm."%'
UNION
SELECT * FROM filesindex WHERE location LIKE '".$searchterm."%'";
Or ideally, is there an easier way that involves less hardcoding to search a table.
Any ideas?
Thanks