Jump to content


This topic is now archived and is closed to further replies.


Prevention of data reloading using filter and sorting

Recommended Posts


Firstly, I' d like to apologize if I can't state my problem cleary (not so good in English). Anyway, here's the deal:

Currently I'm doing a simple project where products are stored in mysql table with their own ID. I want to display all that data in a html table. But the data must be sorttable and in a separate page, users should have the ability to select (via checkboxes) which columns to display. The filtering I've solved relatively easy, but ordering, only partially. So know I need little help. I'll explain the problem using my code:

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]<?php
// Column filter script, which is include only once, due to the reuse of it when a reload button is clicked.

//Here I have a sortting code. It's quite simple.
$default_sort = 'vid'; // Default sort order by first column

if (!isset ($_GET['order'])) // Checking for sort order
{ $order = $default_sort; }
{ $order = $_GET['order']; }

//No comments here :-)
include 'sqlconfig.php';
include 'sqlconnect.php';

//---Fetching and Displaying headings-------------------------------------------
$result = mysql_query("SELECT $filt FROM charts ORDER BY $order") or die (mysql_error());
$row = mysql_fetch_assoc($result);

<table witdh="100%" border="0" cellpading="4" cellspacing="2">
<tr width="100%" bgcolor="#CCCCCC">
if (strstr($filt, vid))
<td><a href="<?php print $_SERVER['PHP_SELF']."?order=vid";?>">ID</a></td>
and etc...

Now, as you can see, I have a not so complex code. Everything is fine, when a user selects which columns to display, and everything is fine, even, when a reload button is clicked, but when the user clicks the header to sort, page reloads with all the columns, not the ones selected by user. It seems, that this click invokes the code to be read entirely from start. The "include_once" does not help here :( How can I write the code, that theclick will only do the reselection of data from table, while not starting from the beginning? And another of topic question: How to make data sort and ASC and DSC by clicking multiple times? :-)

Share this post

Link to post
Share on other sites
Ah, nevermind... After a couple of hours, I've solved this problem with a variable passing using sessions. :-)

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.