How to deliver variable value to different flow when ui-button is pressed

Sorry for the misunderstanding, As you can see from my overall flow here, the button node here is suppose to act like a gate which before it is pressed, no value will be able to pass through it to the function and save it to the MySQL data base.

please have a look at the code in this function node(after button node) , there is 1 line which consist both msg.topic and msg.payload.

Since button can only send msg.topic and msg.payload, lets say if i were to write the code like this:-

if(msg.topic=='pressed')
{
msg.topic = "INSERT INTO table1(value)VALUES(' " + msg.payload + " ');";

}

return msg;

i wont get the value that i desired if i do if(msg.topic=='pressed') condition, my value will become a random string number in mySQL database

or the value turns out to be just "pressed" if i use if(msg.payload=="pressed") condition.

However, if i were to remove this button node, everything works fine.

This is my concept,I am planning to implement a dashboard whereby, if the end-user wants to record this reading, they just have to press the button and the data will be saved in a MYSQL database.

Once again, so sorry for causing a confusion.

Please refer to the image shown in this link.