javascript - PHP - Pagination: $_POST or $_GET -
javascript - PHP - Pagination: $_POST or $_GET -
i'm developing search system(multiple filters) uses pagination php. @ first using method post main form. but, using post unable maintain pagination. reason: when user search name, example, clicks in next pages query lost , homecoming first page. prepare utilize method instead. using get, url gets parameters. , users don't want that.
example:
http://mysearch.com/search.php?name=joe&id=1
i want
http://mysearch.com/search.php
i tried workaround:
if(typeof window.history.pushstate == 'function') { window.history.pushstate({}, "hide", "http://mysearch.com/search.php"); }
but when nail "previous page/back" in browser, url parameters come either.
is there solution this? utilize or post pagination , parameters not shows in url?
you can paginate $_post $_get , without session variables/cookies, need pass pagination variables hidden values in html form.
eg - 2 buttons, 1 of takes previous page, , 1 next:
//prev button <form action="paginate.php" method="post"> <input type="hidden" name="prev" value="0"/> <input type="submit" value="go previous page"/> </form> //next button <form action="paginate.php" method="post"> <input type="hidden" name="next" value="2"/> <input type="submit" value="go next page"/> </form> //search form <form action="paginate.php" method="post"> <input type="hidden" name="prev" value="0"/> <input type="hidden" name="next" value="2"/> <input type="text" name="search" value="user input goes here"/> <input type="submit" value="search database"/> </form>
the disadvantage post give 'page expired' errors when using browser button (but not html buttons), not great. reason i'd prefer $_get, , because can bookmark $_get queries, not $_post.
javascript php jquery pagination
Comments
Post a Comment