I am trying to load a grid with a SQL string. You advised using a session variable. However, I cannot get the load working even using the $_SESSION super global.
I tried using this:
if (!empty($_POST[“ServiceID”]))
{
$_SESSION[“ServiceID”] = $_POST[“ServiceID”];
}
else
{
$_SESSION[“ServiceID”] = “0”;
}
$serviceid = $_SESSION[“ServiceID”];
with this:
$grid->set_options($opt);
if ($serviceid == “0”) {
$grid->select_command = “SELECT ID, instance_date, serviceID FROM serviceinstances”;
}
else {
// $grid->select_command = “SELECT ID, instance_date, serviceID FROM serviceinstances WHERE ID = “.$serviceid;
$grid->select_command = $sql;
}
$grid->table = “serviceinstances”;
Any thoughts?
It DOES work with GET and I don’t need to use a session variable so it looks like an issue with POST vs GET…
Hello,
Your code looks fine except the line in else block is commented out. It this is done intentionally and still not working after uncommenting it, You can share complete grid code file for review.
Yes, POST need data persistence and GET does not require such work around.
Attach code here and paste link in question.
Attach screenshot here and paste link in question.