Hi All,
Grid Doesn't show results when the SQL is created with PHP variables. I'm using the free version of jqgrid.
But when I hardcode the sql in php code, it works.
Following is the code
$g->select_command = "SELECT p.id,c.compName,p.chk_no,p.payAmt,b.bcode,b.bankbranch FROM tblpayments p, tblcustomers c, tblbank_list b WHERE p.cusId=c.id AND p.bankAcc=b.id AND p.logedDate BETWEEN $ff AND $tt;
I've tried with
"… p.logedDate BETWEEN ".$ff." AND ".$tt;
"… p.logedDate BETWEEN '".$ff."' AND '".$tt."'";
When echo this statement, it gives something like this.
SELECT p.id,c.compName,p.chk_no,p.payAmt,b.bcode,b.bankbranch FROM tblpayments p, tblcustomers c, tblbank_list b WHERE p.cusId=c.id AND p.bankAcc=b.id AND p.logedDate BETWEEN 1391299200 AND 1405814399
This has many records.
Please help me to solve this.
The grid is loaded with 2 server calls.
1) load the columns of grid.
2) do an ajax call, to load data of grid.
if you want to use other variables, they is available for step1. But not there in 2nd ajax call, as it is not posted.
Solution is to put those variable in session and use it from session for step2.
e.g.
if (!empty($ff))
{
$_SESSION["ff"] = $ff;
}
$ff = $_SESSION["ff"];
I'm doing this in mine but its still only working on the first call. Not sure if I'm doing something wrong or what. I echo out the sql command to see it and I can see it gets the variable the first call but then second one fails and doesn't make it. It makes no sense that the Session variable isn't even being picked up on the second attempt.