I need to retrieve a string from a query and then use that later on in another SQL query.
This is what I have, I'm retrieving the current branch ID for the currently logged in user:
$neededBranch = mysqli_query($con, "SELECT BranchNumber FROM Staff WHERE staffID = '".$_SESSION['username_login']."'");
And then I need to use said string here like this:
$result = mysqli_query($con, "INSERT INTO SomeTable (
blah,
blah,
)
VALUES ('".$SomeValue."',"
. " '".$_SESSION['username_login']."',"
. " '".$neededBranch."')");
Now, the ". " '".$neededBranch."')");
" does not work because it is expecting a string.
My question is: How do I actually get the value I'm needing from the first query and use it in the second query? I'm new at PHP and don't have a clue.