POST values to SSP and get return results
POST values to SSP and get return results

I have a form with 3 input fields that I would like to send to ssp.class a filter and return the results. I do not want to load DataTables on page load as it does right now.
Any idea how to approach or directions to samples. I pretty new to Datatables.
This discussion has been closed.
Replies
See if
deferLoading
does what you want.Kevin
Thank you but that doesn't do what I need.
When I enter the date and status in the form and submit, it suppose to bring back results that fit the two parameters.
You can use
ajax.data
to send parameters to the server. There are a couple examples of this using functions in the docs.Kevin
I tried ajax.data but still returning all the data. Is there something wrong in my code?
It looks like you're just sending a single constant in
ajax.data
, so it won't filter between two values. You would need to send both values, and then have the server script use the values in its query.Colin
Thank you Colins.
I'm new to this and not clear. I followed one of the examples under ajax.data.
Can you elaborate a little or guide me to samples?
Need some assistance if possible.
I have this code but when I load my page comes up blank.
Is there something I missing?
Can you use the debugger (https://debug.datatables.net) on your page to give me a trace please - click the Upload button and then let me know what the debug code is.
Or even better would be a link to the page showing the issue.
Thanks,
Allan
Thank you Allan.
See the URL below. Also added the reportsearch.php file used for getting the ajax data.
http://www.meimeisfashion.com/cardgen/reports/cardsearch.php
<?php
if(isset($_POST['btnSearch'])){
$bin = $_POST['bin'];
$branch = $_POST['branch'];
$SearchString = "";
//Branch
if(!empty($_POST['branch'])){
$SearchString.= " AND substring(CIFPan, 7, 2) = '".$_POST['branch']."'";
}
//Bin
if(!empty($_POST['bin'])){
$SearchString.= " AND substring(CIFPan, 0, 7) = '".$_POST['bin']."'";
}
if($SearchString != ""){
// DB table to use
$table = <<<EOT
(SELECT T1.RecordId,T1.CIFPan,T1.CIFAcctNum1,T1.CIFFName,T1.CIFLName,
CASE
WHEN T1.CIFCardStat = 00 THEN 'Good'
WHEN T1.CIFCardStat = 01 THEN 'Hot'
WHEN T1.CIFCardStat = 02 THEN 'Warm'
WHEN T1.CIFCardStat = 03 THEN 'Closed'
WHEN T1.CIFCardStat = 04 THEN 'Issue'
WHEN T1.CIFCardStat = 05 THEN 'Do Not Honor'
WHEN T1.CIFCardStat = 06 THEN 'Stolen'
WHEN T1.CIFCardStat = 07 THEN 'Lost'
WHEN T1.CIFCardStat = 08 THEN 'Retain'
WHEN T1.CIFCardStat = 09 THEN 'Restricted'
WHEN T1.CIFCardStat = 10 THEN 'Other'
WHEN T1.CIFCardStat = 11 THEN 'IBanking Approved'
WHEN T1.CIFCardStat = 12 THEN 'IBanking Pending'
WHEN T1.CIFCardStat = 12 THEN 'Pending Activation'
ELSE 'No Available Status'
END as CIFCardStat,
CONVERT(DATE, CIFExpDate,101) as CIFExpDate,
CONVERT(DATE, CIFUpdateDate,101) as CIFUpdateDate,
DATEDIFF(day,GETDATE(),CIFExpDate) as daysToExpire,
CASE
WHEN SUBSTRING((CIFPan), 7, 2) = 00 THEN 'B Street'
WHEN SUBSTRING((CIFPan), 7, 2) = 01 THEN 'Vieu'
WHEN SUBSTRING((CIFPan), 7, 2) = 02 THEN 'GFL'
WHEN SUBSTRING((CIFPan), 7, 2) = 03 THEN 'Rod'
WHEN SUBSTRING((CIFPan), 7, 2) = 05 THEN 'Mar'
WHEN SUBSTRING((CIFPan), 7, 2) = 06 THEN 'Mercu'
WHEN SUBSTRING((CIFPan), 7, 2) = 07 THEN 'Ro'
WHEN SUBSTRING((CIFPan), 7, 2) = 09 THEN 'Jann'
ELSE 'No Available Branch'
END AS branch
FROM zCIFRecord T1
WHERE CIFExpDate != '00/00/0000'
AND CIFUpdateDate != '00/00/0000'
AND T1.CIFDateTime = (SELECT MAX(CIFDateTime) FROM zCIFRecord T2 WHERE T1.CIFPan = T2.CIFPan)
AND CIFUpdateActivity<>'Z' $SearchString ) temp
EOT;
}else{
$table = <<<EOT
(SELECT T1.RecordId,T1.CIFPan,T1.CIFAcctNum1,T1.CIFFName,T1.CIFLName,
CASE
WHEN T1.CIFCardStat = 00 THEN 'Good'
WHEN T1.CIFCardStat = 01 THEN 'Hot'
WHEN T1.CIFCardStat = 02 THEN 'Warm'
WHEN T1.CIFCardStat = 03 THEN 'Closed'
WHEN T1.CIFCardStat = 04 THEN 'Issue'
WHEN T1.CIFCardStat = 05 THEN 'Do Not Honor'
WHEN T1.CIFCardStat = 06 THEN 'Stolen'
WHEN T1.CIFCardStat = 07 THEN 'Lost'
WHEN T1.CIFCardStat = 08 THEN 'Retain'
WHEN T1.CIFCardStat = 09 THEN 'Restricted'
WHEN T1.CIFCardStat = 10 THEN 'Other'
WHEN T1.CIFCardStat = 11 THEN 'IBanking Approved'
WHEN T1.CIFCardStat = 12 THEN 'IBanking Pending'
WHEN T1.CIFCardStat = 12 THEN 'Pending Activation'
ELSE 'No Available Status'
END as CIFCardStat,
CONVERT(DATE, CIFExpDate,101) as CIFExpDate,
CONVERT(DATE, CIFUpdateDate,101) as CIFUpdateDate,
DATEDIFF(day,GETDATE(),CIFExpDate) as daysToExpire,
CASE
WHEN SUBSTRING((CIFPan), 7, 2) = 00 THEN 'Bridge Street'
WHEN SUBSTRING((CIFPan), 7, 2) = 01 THEN 'Vieux Fort'
WHEN SUBSTRING((CIFPan), 7, 2) = 02 THEN 'GFL Charles'
WHEN SUBSTRING((CIFPan), 7, 2) = 03 THEN 'Rodney Bay Mall'
WHEN SUBSTRING((CIFPan), 7, 2) = 05 THEN 'Marigot'
WHEN SUBSTRING((CIFPan), 7, 2) = 06 THEN 'Mercury Court'
WHEN SUBSTRING((CIFPan), 7, 2) = 07 THEN 'Rodney Bay Marina'
WHEN SUBSTRING((CIFPan), 7, 2) = 09 THEN 'Jannou Credit Union'
ELSE 'No Available Branch'
END AS branch
FROM zCIFRecord T1
WHERE CIFExpDate != '00/00/0000'
AND CIFUpdateDate != '00/00/0000'
AND T1.CIFDateTime = (SELECT MAX(CIFDateTime) FROM zCIFRecord T2 WHERE T1.CIFPan = T2.CIFPan)
AND CIFUpdateActivity<>'Z' ) temp
EOT;
}
}
echo $Table;
// Table's primary key
$primaryKey = 'RecordId';
// Array of database columns which should be read and sent back to DataTables.
// The
db
parameter represents the column name in the database, while thedt
// parameter represents the DataTables column identifier. In this case simple
// indexes
$columns = array(
array( 'db' => 'RecordId', 'dt' => 0 ),
array( 'db' => 'CIFPan', 'dt' => 1 ),
array( 'db' => 'CIFCardStat', 'dt' => 2 ),
array( 'db' => 'CIFAcctNum1', 'dt' => 3 ),
array( 'db' => 'CIFFName', 'dt' => 4 ),
array( 'db' => 'CIFLName', 'dt' => 5 ),
array( 'db' => 'CIFExpDate', 'dt' => 6 ),
array( 'db' => 'CIFUpdateDate', 'dt' => 7 ),
array( 'db' => 'Branch', 'dt' => 8 )
);
// SQL server connection information
// SQL server connection information
$sql_details = array(
'user' => '',
'pass' => '',
'db' => '',
'host' => ''
);
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* If you just want to use the basic configuration for DataTables with PHP
* server-side, there is no need to edit below this line.
*/
require( 'scripts/ssp.class.php' );
echo json_encode(
<?php > ?>SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns )
);
First, your page shows numerous errors. Check your browser console.
Second, you are sending POST but expecting GET.
Thank you for your input.
I clear the errors and update to POST but still issue still there. Not sure what's happening.
Your page still has errors.
Thank you. I'm having a little trouble connecting to the database from remote hosting.
I made the changes locally was able to post manually.
When I try posting on click of a button, it doesn't filter and returns all value.
Can you please point me to my mistake and what needs to be done to address?
I just looked at your page (http://www.meimeisfashion.com/cardgen/reports/cardsearch.php) and it's giving a 404
Colin