Quantcast
Viewing latest article 24
Browse Latest Browse All 124

How to pass a PHP form variable to server processing for use in WHERE clause?

I have a form in my application where you select a "customer" and a "startdate" and "enddate".

When the user clicks on "submit", I want to pass these 3 POST variables through to datatables to be used in a WHERE clause to filter the results.

I've tried a bunch of things with no success. Using Firefox I can see the variable "formCustomer" in the "params".

Here's my code but how do I read the "formCustomer" variable in the page "scripts/server_processing_stock.php"?

    <script type="text/javascript" language="javascript" class="init">

        $.extend( $.fn.dataTable.defaults, {
            responsive: true
        } );        
        
        $(document).ready(function() {
            $('#stock_report').dataTable( {
                "language": { "infoFiltered": ""},          
                "order": [[ 1, "desc" ]],
                "processing": true,
                "serverSide": true,
                "ajax": {
                        "type": 'POST',
                        "url": 'scripts/server_processing_stock.php',
                        "data": {
                            formCustomer: '<?php echo $_POST["sel_customer"] ?>',
                        }
                    }

            } );
        } );

    </script>   

Viewing latest article 24
Browse Latest Browse All 124

Trending Articles