I have a problem. I am using mod_rewrite to rename my URLS
Everything is working correctly until I reformatted my URLS so that spaces include - instead of %20.
site.com/page.php?country=abc®ion=d e f&city=gh i
site.com/abc/d-e-f/gh-i/
Currently I am doing this
if (isset($_GET['country'])) {$country = str_replace('-', ' ', $_GET['country']);}
if (isset($_GET['city'])) {$city = str_replace('-', ' ', $_GET['city']);}
if (isset($_GET['region'])) {$region = str_replace('-', ' ', $_GET['region']);}
I then convert back to normal when querying the database for example:
str_replace(' ', '-', $_GET['city'])
However this has created a problem as some cities use both a space AND a -. Saint-andre reunion island.
Initially I thought about running the original SQL query and if 0 results are returned, str_replacing spaces with - before running the query again. However this will only fix it if the city contains ONLY - and 0 space eg Saint-andre.
$sql2 = "SELECT `name`, FROM `list` WHERE country = '$regionCode[0]' AND admin1 = '$regionCode[1]' AND admin2 = '$regionCode[2]' AND city = '$city' ORDER BY 'moddate'";
What is the best way to handle this? Should I use double dashes instead and handle this differently? EG Saint--andre-reunion-island or is there a better way?
Thanks