Lets say I have this page:
example.com/state/california
and I use $_GET
to retrieve that specific page from the DB.
However when I try this page:
example.com/state/new%20york
My page seems to only retrieve "new" instead of "new york"
htaccess:
RewriteRule ^([^\.]+)$ $1.php [NC,L]
RewriteRule ^state/([0-9a-zA-Z]+) location.php?state=$1 [NC,L]
Code:
<?
$state = $_GET['state'];
$sql = "
SELECT
*
FROM
states
WHERE
state = '$state'
";
$records = mysqli_query($db_conx, $sql);
$sql = "
SELECT
*
FROM
states
WHERE
state='$state' LIMIT 1
";
$query = mysqli_query($db_conx, $sql);
$numrows = mysqli_num_rows($query);
if ($numrows < 1) {
echo $state;
exit();
} else {
echo "Welcome to the state of ".$state;
}
?>
I'm not looking for the file name, I'm looking for the last part of the loaded semantic URL.