For example, I want to search multiple names(mark, jake, john, michael) <-- this is typed in a single text field separated by commas.
Then it will go to another page which will show all records from my database having a name of "mark", "jake", "john", or "michael".
This is my initial code (page afrer clicking the search button) result.php:
Expand|Select|Wrap|Line Numbers
- $search = $_POST["search"];
- $array_search = explode(',', $search);
- $imploded_search = implode(",", $array_search);
- $query = mysql_query("SELECT * FROM users WHERE name IN($imploded_search)");
- while ($row = mysql_fetch_array($query))
- {
- echo $row['name'];
- }
When I added '' in $imploded_search in
Expand|Select|Wrap|Line Numbers
- $query = mysql_query("SELECT * FROM users WHERE name IN('$imploded_search')");
I believe that $imploded_search creates one string 'mark, jake, john, michael' =
Expand|Select|Wrap|Line Numbers
- $query = mysql_query("SELECT * FROM users WHERE name IN('mark, jake, john, michael')");
Expand|Select|Wrap|Line Numbers
- $query = mysql_query("SELECT * FROM users WHERE name IN('mark', 'jake', 'john', 'michael')");
I need help on how to do this.
THANK YOU VERY MUCH in advance!