Hi, I am trying to select data to other table but unfortunately i always got error on this.

PHP Code:
       $cn=$db->prepare("select empid,empjob
                          from employee"
);
        
$cn->execute();

        while(
$row =  $cn->fetch(PDO::FETCH_ASSOC)){
                 
$empid $row['empid'];
          
                     
$cn=$db->prepare("select actempid, actaddress
                          from empact
                         where actempid = 
$empid");
                        
$cn->execute();

                
some codes ............
              ................................
           
        } 

is this okay to use ?please correct me if i am wrong.

Thank you in advance.