I'm trying to get the user's ID number from my table. For some reason the value always comes up "NULL", and it shouldn't be but I can't figure out what I'm doing wrong here.
Here is how my table 'users' looks:

<?php
...........................................
....connection details (connection is not the problem as other SQL queries in my code work fine)
...........................................
...........................................
$getvals = $db->prepare("SELECT MFG_LINE, PM_MECHANICAL, PM_DESIGN, PM_APPLICATIONS, PM_PROGRAM, DESCRIPTION FROM new_schedule WHERE ITEM = '$jobnum'");
$getvals->execute();
while ($row = $getvals->fetch(PDO::FETCH_ASSOC)){
$prod_line=$row["MFG_LINE"];
$pe=$row["PM_MECHANICAL"];
$de=$row["PM_DESIGN"];
$ae=$row["PM_APPLICATIONS"];
$ce=$row["PM_PROGRAM"];
$model=$row["DESCRIPTION"];
}
/*Is job PE, DE, or CE?*/
$engtype = rand(1,3);
if ($engtype===1) { $engineer = $pe; }
else if ($engtype===2) { $engineer = $de; }
else if ($engtype===3) { $engineer = $ce; }
else { $engineer = "Error 1005"; }
echo $engineer;
if ($engineer == null || $engineer = "") {
$theengineer = 0;
echo "nope";
} else {
$getidnum = $db->prepare("SELECT USERID FROM users WHERE fullname LIKE '$engineer'");
$getidnum->execute();
$getthenum = $getidnum->fetch(PDO::FETCH_ASSOC);
$theengineer = $getthenum['USERID'];
}
?>
The value is returning a NULL value when it should be returning "12". What am I missing here?
var_dump($getthenum)what do you get?SELECT USERID FROM users WHERE fullname LIKE 'BRAD DAVIS'from a MySQL client, whats the output?$engineervalue