0

value is Tourism & Hotels

url?catagory=Tourism%20&%20Hotels&maincateg=Tourism%20&%20Hotels

if i call that catagory to another page

$category = $_GET['catagory'];

and in second page i displayed that value

echo $category;

but this showing only Tourism and the remaining words r gone.i want to display Tourism & Hotels with special char

3
Contributors
6
Replies
30
Views
3 Years
Discussion Span
Last Post by malatamil
0

is it correct

echo encode($category);

i used this one but its not working

0

If you encode it, remember to encode your values before building the querystring. If you try to urlencode after building the complete querystring, you'll end up encoding the '&' querystring-pair separator and the '=' too.

If the category is "Tourism & Hotels"

then encode, e.g.

$raw = "Tourism & Hotels";
$enc = urlencode($raw);

$url = '?category=' . $enc . '&maincateg=' . $enc;

//then

<a href="<?php echo $url;?>"><?php echo $raw;?></a>

So, test something like this...

<?php
if($_GET)
{
    echo "<pre>";
    print_r($_GET); 
    echo "</pre>";
}

$raw = "Tourism & Hotels";
$enc = urlencode($raw);

$url = '?category=' . $enc . '&maincateg=' . $enc;
?>

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<a href="<?php echo $url;?>"><?php echo $raw;?></a>
</body>
</html>    

Not sure if that's what you want though.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.