【发布时间】:2015-12-15 12:16:09
【问题描述】:
我在这个网站上尝试了很多可用的选项,但无法解决我的问题。 我的代码:
<?php
$district = $_GET['district'];
$state = $_GET['state'];
$con = mysqli_connect('localhost','codeslib_service','service','codeslib_vdr123');
if (!$con) {
die('Could not connect: ' . mysqli_error($con));
}
// the query, limit the number of results to 5
$sql="SELECT * FROM pincodes WHERE districtName='$district' AND stateName='$state'";
$result = mysqli_query($con,$sql);
$row = $result->fetch_assoc();
$district = $row['districtName'];
$office = $row['officeName'];
$state = $row['stateName'];
$pincode = $row['pinCode'];
?>
.htaccess:
RewriteRule ^([^/]*)/([^/]*)$ district.php?state=$1&district=$2 [L]
现在,上面的代码正在生成像domainname.com/pincode/Delhi/Andhra Pradesh这样的URL
虽然我不想在 URL 中有空格,但想用连字符 (-) 替换空格。 尝试了很多东西但没有任何收获,请帮助我。
谢谢,
维卡斯
【问题讨论】: