2 tables in the Server Processing Page. How to join query them?

2 tables in the Server Processing Page. How to join query them?

vladivostokvladivostok Posts: 2Questions: 0Answers: 0
edited June 2012 in DataTables 1.8
Hello

I have 2 questions:


1 )How do you work with 2 tables on the Server Side Processing page? I have a join query. that would pick the parameters from the select list and would send them to the processing page. In the array of columns I would have to have all the columns involved from both tables, but also in that page I see a mention to $tablename, what do I do if I have two tables? Here below is a mock of what one value from the select list would be, though I would still need two more from the other select lists. The code is almost finished, but I ain't getting it right.

Does anybody know how to solve this ?


2) I have 3 select lists, They are not interdependent. How can I pass the values from the Selected Lists into this code below so that it is forwarded to the server_processing.php page. I have hardcoded the values, like Poland, Russian and Lithuanian, down below, but I would need to be passed from the Select Lists.





Thank you



Code:

[code]

$(document).ready(function() {
$('#shops').dataTable( {
"bProcessing": true,
"bServerSide": true,
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"sAjaxSource": "datatables/php/server_processing_shops.php",
"fnServerData": function ( sSource, aoData, fnCallback ) {
/* Add some extra data to the sender */
aoData.push( { "name": "Country", "value": "Poland", "name": "From_language", "value": "Russian", "name": "Into_language": "value": "Lithuanian" } );
$.getJSON( sSource, aoData, function (json) {
/* Do whatever additional processing you want on the callback, then tell DataTables */
fnCallback(json)
} );

[/code]


Then, in the server_processing.php page I have

$sTable = "translator";
$stable2 = "work_assignment";
$tablename = "translator";

[code]


if ( $sWhere == "" ) {
$sWhere = "WHERE Country= '".mysql_real_escape_string($_GET['Country'])."'";
$sWhere = "WHERE From_language= '".mysql_real_escape_string($_GET['From_language'])."'";
$sWhere = "WHERE Into_language= '".mysql_real_escape_string($_GET['Into_language'])."'";
$sWhere = "WHERE Translator.Translator_ID= '".mysql_real_escape_string($_GET['work_assignment.Translator_ID'])."'";

} else {
$sWhere .= " AND Country= '".mysql_real_escape_string($_GET['Country'])."'";
$sWhere .= " AND From_language= '".mysql_real_escape_string($_GET['From_language'])."'";
$sWhere .= " AND Into_language= '".mysql_real_escape_string($_GET['Into_language'])."'";
$sWhere .= " AND Translator.Translator_ID= '".mysql_real_escape_string($_GET['work_assignment.Translator_ID'])."'";

}

*/
$sQuery = "
SELECT SQL_CALC_FOUND_ROWS ".str_replace(" , ", " ", implode(", ", $aColumns))."
FROM $sTable, $sTable2
$sWhere
$sOrder
$sLimit
";


$sQuery = "
SELECT COUNT(".$sIndexColumn.")
FROM $sTable, $sTable2

And then, finally,

$sOutput .= '"'.addslashes($aRow['Country']).'",';

[/code]
This discussion has been closed.