使用Php Get方法在URL中更新空间到连字符

I would like to update space to hyphen in my php url file via get method. I have tried some methods, but i got an error.

For an example, the original url is pindtrict.php?ste=Tamil Nadu

i want optimized url as, pindtrict.php?ste=Tamil-Nadu

How to do this? Here it is my code,

<?php
include(config.php');
$state_content= "";
$qry = "SELECT DISTINCT State_N FROM pin_data ORDER BY State_N ASC";
$result = mysql_query($qry);
while($row = mysql_fetch_array($result))
    {
        $state_content .= "<li><a href='pindtrict.php?ste=".$row['State_N']."'> ".$row['State_N']."</a></li>";
    }
mysql_close();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Pincode Directory</title>
<body>
<div>
    <?php echo $state_content; ?><br />
</div>
</body>
</html>

Use

$state_content .= "<li><a href='pindtrict.php?ste=".str_replace(' ', '-',$row['State_N'])."'> ".$row['State_N']."</a></li>";

Anything that goes in the url as a query parameter needs to be urlencoded using urlencode(). For replacing part of string, use str_replace

"<li><a href='pindtrict.php?ste=".urlencode(str_replace(' ', '-',$row['State_N']))."'> ".$row['State_N']."</a></li>";