I've found the UserID for the logged in user, and DivID and am storing it in php variables..
$UserID = $_GET['UserID'];
$DivID = $_GET['DivID'];
My PDO query finds ALL the users ID's within the specified DivID..
$query = $con->prepare("SELECT e.id AS empid FROM employees e WHERE divid=?");
$query->execute([$DivID]);
I understand how to loop through the results for display w/in the body of my page like so.
<?php while ($row = $query->fetch())
{ #LOOP THROUGH MY RESULTS HERE };?>
However, I would like to create an IF statement in the body of my page, to display data ONLY if the UserID is within the found query set.
<?php if ($UserID *is within* $row['id'])
{ *Display my Data* }
else
{ *Display Different Data* };?>
I've been trying different ways for a few days now. I've read about fetchAll() but could not get that to display anything for me and am not sure if that is the way to go. Any help is greatly appreciated. Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire