A method of treating infection by Staphylococcus in a subject by administering a pharmaceutical composition including a celecoxib derivative of formula I or a pharmaceutically acceptable salt thereof is described. The preparation of numerous celecoxib derivatives for testing as potential anti-staphylococcal agents is also described.