Hi all,
I have a postcode field which i need to search on to find any postcodes that match the users search.
The postcode is seperated by commas for each record.
e.g.
postcode
W10,W11,W2,W3
how can i do this?
SEARCH HELP
Moderator: General Moderators
This should work:
Code: Select all
SELECT
*
FROM
myTable
WHERE
postcode LIKE '%user_entered_string%'Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
if the commas separate potential values on the db, you can use "IN" in your search query:
if you're searching strings...which it looks like you are, you'll need to throw single quotes around each "value".
let me know if you need help with that.
Code: Select all
$query = "select * from myTable where someField IN(".$_POST['somePostField'].")";let me know if you need help with that.