The improper utilization of nitrobenzene (NB) and ornidazole (ORN) has resulted in irreversible effects on the environment. By combining experimental investigation, density functional theory (DFT) calculations, and machine learning, an effective green strategy for detecting NB and ORN in aqueous solutions can be developed. In this study, a one-dimensional Cd-based coordination polymer (Cd-HCIA-3) was designed and synthesized using 5-((4-carboxybenzyl)oxy)isophthalic acid and rigid 2,2′-bipyridine under solvothermal reaction conditions. Cd-HCIA-3 exhibits excellent fluorescence properties and stability in aqueous solutions. DFT calculations were performed to predict the fluorescence sensing performance of Cd-HCIA-3, revealing that photoinduced electron transfer is the key mechanism for inducing fluorescence quenching in the presence of NB and ORN, with weak molecular interactions promoting electron transfer. Fluorescence sensing experiments were conducted to verify the DFT results, showing that Cd-HCIA-3 can selectively detect NB and ORN in aqueous solutions with limits of detection of 7.22 × 10−8 and 1.31 × 10−7 mol/L, respectively. This study’s findings provide valuable insights into the design and synthesis of fluorescent coordination polymers for target analytes.