Reputation: 393
Following on from my last question:
I am now using the statement:
if (isset($_GET['url'])) {
$url = $_GET['url'];
}
SELECT name, url FROM table WHERE species LIKE '%$url%'
species
could have content likes "Brown & Rainbow Trout, Pike"
however my url for say Brown Trout is : /fishing/browntrout/
This basically prevents the statement above from returning any results.
Clearly it works fine for say : /fishing/pike/
just not for the fish that have 2 names.
Whats the best way to resolve this?
Upvotes: 1
Views: 12822
Reputation: 227230
Try making the url /fishing/brown_trout/
instead. Then try something like this:
if (isset($_GET['url'])) { // "brown_trout"
$url = str_replace('_', '%', $_GET['url']); // "brown%trout"
}
SELECT name, url FROM table WHERE species LIKE '%$url%'
This will make the query:
SELECT name, url FROM table WHERE species LIKE '%brown%trout%'
Which should work.
Upvotes: 1