How to work with $_SERVER['QUERY_STRING']

后端 未结 3 475
不知归路
不知归路 2020-12-28 09:35

How to work with $_SERVER[\'QUERY_STRING\'] and pagination?

When my table is sorted by this link:



        
3条回答
  •  长情又很酷
    2020-12-28 09:59

    Instead of reusing QUERY_STRING, you should assemble it anew with http_build_query().

    // Merge $_GET with new parameter
    $QS = http_build_query(array_merge($_GET, array("page"=>2)));
    
    // You should apply htmlspecialchars() on the path prior outputting:
    echo " $i ";
    

    Thus you have all current $_GET parameters included, but can add or replace entries with new values. And it's ensured that each appears only once.

提交回复
热议问题