Where Clause

QuestionsWhere Clause
Bruce asked 3 years ago

So I’m trying to do something really basic with an SQL command but it needs a WHERE clause in it. The reason is because a previous page with a grid on it is sending this page a value for an ID. So this is sort of the example:

$g->select_command = “SELECT * FROM my_table WHERE myid=$myid”;

No matter what I do, the $myid value is ignored. I’m figuring the WHERE clause is being knocked out and I’m getting an error or no records. I know the value is getting there, and if I replace the $myid with a value like “1” it works which is even more strange. Any thoughts or suggestions since these are $_POST variables being pushed to the page.

5 Answers
Abu answered 3 years ago

Hi,

You can refer this faq:

https://www.gridphp.com/docs/misc-faqs/#q-how-to-load-grid-based-on-_post-data-from-other-page

We are in Asia/pk, if you still have issues, I will be updating back in working hours.

Abu Ghufran Staff replied 3 years ago

Please let me know if you need further help.

Bruce Rick answered 2 years ago

I’m having the exact same problem, and getting no where. I’ve created the $_SESSION variable and then the $pid variable as suggested here. I just keep getting the same error. I wondering if I’m calling the $_SESSION variable in the wrong location or something similar, it’s just making no sense.

<script src=”https://gist.github.com/bruceits/91e50f1fb3340c6ca41c62142cab88bf.js”></script&gt;

View post on imgur.com

Bruce Rick answered 2 years ago

This is the location of the source, looks like my last post screwed up:

https://gist.github.com/bruceits/91e50f1fb3340c6ca41c62142cab88bf

Abu Ghufran Staff answered 2 years ago

Hi,

Try changing line 16-19 with:


// get the oemid from the Post
$oemid = filter_input(INPUT_POST, 'oemid', FILTER_SANITIZE_NUMBER_INT);
if (!empty($oemid)) $_SESSION['oemid'] = $oemid;

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Bruce Rick answered 2 years ago

Abu,

This worked. You are awesome. I thought I had done this 10 times over but this makes sense.

Thanks Again,

Bruce

Your Answer

8 + 11 =

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?