The hair loss
certainly could be related to a scalp infection causing your dandruff
, so it best to treat the dandruff/infection.
Try head and shoulders medicated shampoo to start and see a dermatologist if the condition does not improve, as there are other causes too that may cause hair loss. Best wishes.