I'm using OctoberCMS based on Laravel.
I have an html search field which query string is parsed with php.
Laravel returns database results based on the url tag
parameter using MySQL WHERE LIKE
.
It works with 1 tag, but how to return results matching multiple tags separated by commas or spaces?
<form action="/search">
<input type="search" name="tags" multiple>
<button type="submit">search</button>
</form>
localhost/search?tags=galaxy
commas localhost/search?tags=galaxy%2C+stars%2C+universe
spaces localhost/search?tags=galaxy+stars+universe
This should return any tags matching in the database table's tags column.
The problem is that it sees the query as galaxy AND stars AND universe
and not individual tags: galaxy
, stars
, universe
.
$query_string = $tags = '';
$query_string = getenv('QUERY_STRING');
// Return search results matching query string
return $query->where('tags', 'like', "%$tags%");
$query is part of OctoberCMS.
Confusing,. Try logical OR to find value in table column may be it will help, if your finding it from webpages first fetch meta tags in function like google use keyword for search result
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.