sqlFilters with post method

Discuss MySQL Ajax Table Editor

sqlFilters with post method

Postby eleymonster » Thu Aug 06, 2015 1:39 pm

Hi,

Before displaying a page with my table on it I have the user make a selection from a drop down and then submit this via the post method.

I want to use the value of the post to filter my table.

I'm using the code below but the result is an empty table.
Code: Select all
$this->Editor->setConfig('viewQuery',true);
$query = $_POST['id2'];
$this->Editor->setConfig('sqlFilters', "id = '".$query."'");


Below is the viewQuery output
Code: Select all
select `purchase`.`ponumber`,
`purchase`.`id`,
concat(suppliers_0d594_0.sup_name) as `sup_id`,
concat(customers_54543_1.cust_name) as `cust_id`,
concat(cc.cat) as `cc_id`,
cc.markup as `markup`,
`purchase`.`DOP`,
`purchase`.`chargeable`,
`purchase`.`DESCR`,
`purchase`.`COG`,
`purchase`.`SRN`,
`purchase`.`charged`
from purchase
left join `suppliers` as `suppliers_0d594_0` on `purchase`.`sup_id` = `suppliers_0d594_0`.`sup_id`
left join `customers` as `customers_54543_1` on `purchase`.`cust_id` = `customers_54543_1`.`cust_id`
left join `cost_code` as `cc` on `purchase`.`cc_id` = `cc`.`cc_id`
where id = ''
order by `ponumber` desc limit 0, 20


I know the value is definitely posted because when I echo $query, a value is displayed.

Can anyone tell me where I'm going wrong?

Thanks,
Grant
eleymonster
 
Posts: 2
Joined: Mon Jul 13, 2015 2:00 pm

Re: sqlFilters with post method

Postby buconet » Tue May 10, 2016 3:20 pm

hi eleymonster, some days ago had the same problem with the filter and the passage of SQL variables by POST or GET finally what I did was read the variables that come and pass it to _SERVER [ ' PHP_SELF '] $ in the PRO version .

here it is what he does, from an external file named inventario.php , this makes the call of another file named inventario_puro.php and loads it into an iframe , I leave the line of source code so you can understand better.

Code: Select all
<iframe src="http://localhost/CNA/CRAE/inventario_puro.php?idcrae='.$id_crae_en_linea.'&namecrae='.$name_crae.'" width="1200" height="1020" frameborder=0 scrolling=yes > </iframe>


as you can see I am sending two variables one that is to idcrae and the other is namecrae

Now in inventario_puro.php file that implements the PRO version of AjaxTableEditor I modified the following lines :

Code: Select all
var '.$this->instanceName.' = new mate("'.$this->instanceName.'");
            '.$this->instanceName.'.setAjaxInfo({url: "'.$_SERVER['PHP_SELF'].'", history: true});


the change by these

Code: Select all
var '.$this->instanceName.' = new mate("'.$this->instanceName.'");
            '.$this->instanceName.'.setAjaxInfo({url: "'.$_SERVER['PHP_SELF'].'?idcrae='.$_GET["idcrae"].'&namecrae='.$_GET["namecrae"].'", history: true});
            
            


Here I get the values ​​of the variables and assign it in the config URL ajax

and finally the function of initiateEditor ( ) only send the configruacion for filters :

Code: Select all
 $this->Editor->setConfig('sqlFilters', "inventario.IDCRAE = ".$_GET['idcrae']);


when idcrae corresponds to CRAE 03
Image

when idcrae corresponds to CRAE 05
Image

:D ;)
buconet
 
Posts: 28
Joined: Thu May 15, 2014 8:32 pm

Re: sqlFilters with post method

Postby Richy » Thu Dec 22, 2016 11:53 pm

Is there any easier method? We can't use $_GET method too and looking help. Thanks!
Richy
 
Posts: 2
Joined: Thu Dec 22, 2016 11:52 pm

Re: sqlFilters with post method

Postby Richy » Thu Dec 22, 2016 11:55 pm

PS: We use free version.
Richy
 
Posts: 2
Joined: Thu Dec 22, 2016 11:52 pm

Re: sqlFilters with post method

Postby KarelB » Mon Jan 02, 2017 7:24 am

HI,

In the HowTo section there is a topic "Passing $_GET variables".
This explains exactly what you want to do.

Cheers

KArel
KarelB
 
Posts: 458
Joined: Mon Dec 01, 2008 11:49 pm
Location: The Netherlands


Return to Open Discussion

Who is online

Users browsing this forum: Google [Bot] and 5 guests

cron