POST not working for setting initial query

QuestionsPOST not working for setting initial query
Paul Whitfield asked 2 years ago

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…

1 Answers
Abu Ghufran Staff answered 2 years ago

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.

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Your Answer

0 + 6 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?