Jump to content


Photo

Prevention of data reloading using filter and sorting


  • Please log in to reply
2 replies to this topic

#1 Hephaestus

Hephaestus
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 01 March 2006 - 03:38 PM

Hello,

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.
include_once("filterscript.php");


//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; }
else
{ $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">
<?php
if (strstr($filt, vid))
{?>
<td><a href="<?php print $_SERVER['PHP_SELF']."?order=vid";?>">ID</a></td>
<?php
}
and etc...
[/quote]

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? :-)



#2 Hephaestus

Hephaestus
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 02 March 2006 - 12:19 PM

Anyone? :(

#3 Hephaestus

Hephaestus
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 02 March 2006 - 02:38 PM

Ah, nevermind... After a couple of hours, I've solved this problem with a variable passing using sessions. :-)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users