The below is my source code where I want to use the variable $r1 which is at the bottom php script in another php script which is on top on the same page. I need a simple solution which solves this problem. I want to use that variable in the update query which is present in the code.The below is my source code where I want to use