I am trying to search three columns of a database.
Below is the code I was thinking that the code I needed.
I get everything from the database when I search, and I get the same results no matter what I search.
Pickle,
I tried your idea and this is what I got :
SELECT * FROM mountzion WHERE author LIKE "%spurgeon%" OR title LIKE "%spurgeon%" OR topic LIKE "%spurgeon%"
Does that look right?
ReverendDexter,
I do not know of any other way of getting data besides SELECT.
I am trying to figure out why I am not getting any data.
That's a perfectly fine query. If you're getting ALL rows returned when you run that query, then every row in your table has 'spurgeon' in either the `author`, `title`, or `topic` field - there's no other explaination.
As for getting the same results every time... it could be a couple of things. Either your query is the same each time regardless of what you search for, or each row in the table is identical & always contain a word you're searching for. Try searching for something completely junk (like ' asdfasd789459a8d' ) & see if it returns anything.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Ok, that's fine - that just means that there are no rows that match your search string - so the problem of getting the same results no matter what you search has either gone away or never existed. Your other problem of getting everything from the database when you search is also not always happening.
So, we're going to need some more detail on exactly when the problem happens & what you've tried.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
I think that the problem is happening in the displaying.
If the query is fine, it makes sense that it would be the output.
But what the problem is, I do not know.