What you're talking about is known as URL encoding, and has nothing to do with SQL injection. URL encoding is done to prevent confusion with the following characters which have special meaning:
! * ' ( ) ; : @ & = + $ , / ? # [ ]
%21 %23 %24 %26 %27 %28 %29 %2A %2B %2C %2F %3A %3B %3D %3F %40 %5B %5D
This is done automatically by the browser, and you do not need to set anything up server-side for your users. However, you can make use of urlencode()
if you need to pass an encoded string, and urldecode()
if you need to find what the string used to be.
To prevent SQL injection, the most important thing to do is make use of prepared statements. In procedural MySQLi, this would look like:
$stmt = $conn->prepare('SELECT * FROM table WHERE field = ?');
$stmt->bind_param('s', $variable);
$stmt->execute();
For additional preventative measures, I would recommend referring to this post.