Tuesday, August 25, 2015

get current url query string and change then redirect. (modifying URL in PHP)

lets say your current url is
abcd.com/index.php?r=employee_list&search=sudhir&l1=0&l2=5

where l1= limit 1
and  l2= limit 2

you want to make pagination and want to change the limit 1 value.

code

$_GET['l1']=6;
$queryString = http_build_query($_GET, '', '&');

now  your query is r=employee_list&search=sudhir&l1=6&l2=20

header ("Location: http://abcd.com/".$queryString ); // redirect to same page with new range

No comments:

Post a Comment