Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

UPDATE statement by pressing a button

Questions related to using nuBuilder Forte.
Post Reply
marcus
Posts: 20
Joined: Mon Nov 29, 2021 10:16 am

UPDATE statement by pressing a button

Unread post by marcus »

Hello, I want to run a MySQL UPDATE statement by pressing a Button in nuBuilder and using Hash Cookies to modify the statement. What is the most simple way to achieve this?
Best Regards
marcus
kev1n
nuBuilder Team
Posts: 4297
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: UPDATE statement by pressing a button

Unread post by kev1n »

Hi Marcus,

Add an onclick event to your button with a code like

Code: Select all

nuSetProperty('Your_Hash_Cooke','your string here');
nuRunPHPHidden('Your_Procedure_Name', 0);

Next, create a (PHP) Procedure with a code like:

Code: Select all

$hashCookie = "#Your_Hash_Cooke#";
nuRunQuery("UPDATE ...");
marcus
Posts: 20
Joined: Mon Nov 29, 2021 10:16 am

Re: UPDATE statement by pressing a button

Unread post by marcus »

Hello kev1n,
thanks for your reply, it works perfectly!
How can I pass on multiple hash cookies to the query?
kev1n
nuBuilder Team
Posts: 4297
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 444 times
Contact:

Re: UPDATE statement by pressing a button

Unread post by kev1n »

Either by setting each Hash Cookie with nuSetProperty(), using a different hash cookie name

Code: Select all

nuSetProperty('Your_Hash_Cookie_1','your string here');
nuSetProperty('Your_Hash_Cookie_2','your other string here');
... or by using nuRunPHPHiddenWithParams()

Example:

Code: Select all

nuRunPHPHiddenWithParams('your_procedure_name_here', 'param', {param1: 'value1', param2: 'value2'}, 0);   

And in the PHP code, retrieve the parameters:

Code: Select all

$param = json_decode(base64_decode('#param#'));
$param1  = $param->param1;
$param2  = $param->param2;
marcus
Posts: 20
Joined: Mon Nov 29, 2021 10:16 am

Re: UPDATE statement by pressing a button

Unread post by marcus »

Hello kev1n, thank you very much! It works again perfectly!
Post Reply