In order to ilustrate how this can be done We will use our example
Let suppose that we want to display the orders at certain number depending on the session variable which should be set before executing the script.The script can look like this:
<?php require_once 'jq-config.php'; // include the jqGrid Class require_once "php/jqGrid.php"; // include the PDO driver class require_once "php/jqGridPdo.php"; // Connection to the server $conn = new PDO(DB_DSN,DB_USER,DB_PASSWORD); // get the variable $param1 = $_SESSION['ordernum']; // Create the jqGrid instance $grid = new jqGrid($conn); // Write the SQL Query $grid->SelectCommand = 'SELECT OrderID, OrderDate, CustomerID, Freight, ShipName FROM orders WHERE OrderID > ? '; $grid->dataType = "json"; // pass the parameter $grid->queryGrid(null, array($param1)); ?>
All the parameters should be passed whitin arrary and the number of the placeholders ? should equal of length of the array.
You can pass as many parameters as you want.
As you can see the array is passed as second argument of the queryGrid method.