Okay, there could be a few different reasons for why you're having this problem.
- WiFi - test the WiFi on your iPhone by simply connecting to your WiFi and turning off cellular data and looking something up in Safari. If the connection is good and you can look up the page, this isn't your issue
- Data - test your cellular data by turning off WiFi and looking up a page in Safari, same as the WiFi test.
If it's not a problem with either of these try force shutting down your iPhone by holding the lower volume button and power button for about 10 seconds. Then hold the power button to turn the phone back on.
Finally if none of these steps worked try following this guide to help you out: https://support.apple.com/en-us/HT204027