My dad needs some anti-inflammatory painkillers but cannot take ibuprofen as he has had stomach ulcers in the past. What would be the best for him?

Go see family doctor. All non-steroidal anti-inflammatory drugs (nsaids) such as otc Ibuprofen & Naproxen can increase risk for stomach ulcers, even bleeding. This risk can be mitigated to some extent by taking proton pump inhibitors such as Omeprazole & Pantoprazole but these are not w/o risk themselves. Talk to family doc about options such as scheduled acetaminophen, tramadol & opioids. Every drug has some risk.