Need some help in keeping query string values intact while moving across pages via pagination.
Thing is that I'm fetching records from mysql table and displaying it in tabular format. Its like...
I have a page "records.php"
In phpmyadmin there is "userdetails" table with columns as...... first_name, last_name, address, contact_number
First-Name | Last-Name | Address | Contact-Number
I'm trying to sort these elements.... I mean sort by first name or contact number etc...
So I've made <th> elements as links and I'm using querystring... on click the links are directing to same page records.php
so its like...
<th><a href="records.php?idfield=first_name">First Name</th>
<th><a href="records.php?idfield=last_name">Last Name</th>
and so on....
then I initialize on top a variable.
and then this variable $colfield, I'm using in mysql query...
$sql ="SELECT * FROM userdetails order by $colfield ASC";
So, here I'm passing idfield value as per the column name in the database table and then using it in order by clause in sql query.
This works fine... Issue starts when pagination comes into play.... Say I sort by first name, It gets sorted, but when I go to Page 2... the first_name field won't pass in query string... and the order by clause fails... and no records are displayed.
Is there any way to keep query string intact across pagination links....??