Dear all,

I have a string array “$query_string1” having the value (reg_personal.personal_sex=’Male’)
I want to pass this value through the URL for the use of pagination..
For that I used the command “<a href='{$_SERVER}?pageno=1&query_string=$query_string1'>First</a>

When I am clicking on the Link First the passed query string contains only
“Reg_personal.personal_sex=” It is missing the ‘Male’ Part……..

Is there any way to pass that ‘Male’ part also through the url…

Please help me..
Thanks in advance,
Jino.

For what i can see the problem is that PHP dosent interpret the code inside single quotes(') it treats all like a string. so i recomend you change your code to this

<?php
	$query_string1 = "reg_personal.personal_sex='Male'";
	
	echo "<a href=\"".$_SERVER['PHP_SELF'] ."?pageno=1&query_string=" . $query_string1 . "\">First</a>";
	
?>

The url generated by that code is:
http://localhost/teste.php?pageno=1&query_string=reg_personal.personal_sex='Male'

In order to avoid future problems with getting values from the url i strongly advise you to use the functions urlencode() and urldecode(), these 2 functions will format a string in order to be passed in a url and back to variables again.

As URL parameters work like couples this:
&query_string=reg_personal.personal_sex='Male'
may cause problems because of the two attribution signs (=) so if you use urlendode you will have something like this:

<?php
	$query_string1 = urlencode("reg_personal.personal_sex='Male'");
	
	echo "<a href=\"".$_SERVER['PHP_SELF'] ."?pageno=1&query_string=" . $query_string1 . "\">First</a>";
	
?>

that will outup a URL safe address that you can catch and manipulate data without problems, like this one:

http://localhost/teste.php?pageno=1&query_string=reg_personal.personal_sex%3D%27Male%27

urldecode() will convert this data reg_personal.personal_sex%3D%27Male%27 to the original format, something like this:
reg_personal.personal_sex='Male'

hope it helps

This article has been dead for over six months. Start a new discussion instead.