filtering down through links for subsets WHERE...
filtering down through links for subsets WHERE...
opalepatrick
Posts: 2Questions: 0Answers: 0
I might be wording this incorrectly, but...
I want to simply click though a link on a row to create/get a new table as a category/subset of the original. Obviously I need to add a parameter to the WHERE clause, but I cant work out the serverside php code. I dont want to mess up the filtering by rows etc, so looking for some help. Basically I want to SELECT CATEGORY, OTHER_DATA FROM TABLE WHERE CATEGORY = PARAMETER
Must be something in the forum, but I am not asking the right question I think. It is just trying to format the WHERE part of the query?
Thanks
Edit: changed title to be a bit clearer
I want to simply click though a link on a row to create/get a new table as a category/subset of the original. Obviously I need to add a parameter to the WHERE clause, but I cant work out the serverside php code. I dont want to mess up the filtering by rows etc, so looking for some help. Basically I want to SELECT CATEGORY, OTHER_DATA FROM TABLE WHERE CATEGORY = PARAMETER
Must be something in the forum, but I am not asking the right question I think. It is just trying to format the WHERE part of the query?
Thanks
Edit: changed title to be a bit clearer
This discussion has been closed.
Replies
Thanks for the explanation of what you are looking for. To answer fully, I think I might need a little bit more information I'm afraid - specifically, are you going to be reusing the same PHP script as DataTables does for server-side processing, but basically you just want to send an extra parameter which will force extra filtering? Also, are you defining a new DataTable for every row that you can to get the details clause for?
If you are defining a new DataTable then when you construct it, just pass the extra parameter as part of the GET string (i.e. "sAjaxSource": "myScript.php?extra=value", ...). If however you are reusing a DataTable, then you could use fnServerParams and just call fnDraw on the target table (which will then get new data from the server, with the updated fnServerParams option).
On the server-side what you will want to do is something like this: taking http://datatables.net/development/server-side/php_mysql as a base - on line 117 you could add:
[code]
if ( isset( $_GET['extra'] ) ) {
$sWhere .= " AND myColumn = '".mysql_real_escape_string($_GET[extra])."'";
}
[/code]
If you run into any problems with this, just met me know :-)
Regards,
Allan