What you're talking about is using rewrite rules in an .htaccess file.
It takes a few steps to do.
Create an .htaccess file if you don't already have one.
Create your rewrite rule
Change the links on your page to match the new rewrite rule.
Change your sql query
Example:
You have a link to a page like this... example.com/products.php?id=24
You want your URL to look like this... example.com/belgian-coffee
Step 1) make your rewrite rule in .htaccess like this...
RewriteEngine On # Turn on the rewriting engine
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([A-Za-z0-9_-]+)$ products.php?id=$1 [NC,L] # Handle page requests`
Step 2) change the link from <a href="/products.php?id=24">Belgian Coffee</a> to <a href="/<?php echo str_replace(' ', '-', $row['ProductName']) ?>">Belgian Coffee</a>
Note: The str_replace function will replace any spaces in your product name to hyphens
Step 3) Before you query the database for the product name "reverse engineer" your passed parameter. In this case... belgian-coffee like this...
$productname = str_replace('-', ' ', $_GET['id'])
Step 4) Change your sql statement to query for the product name instead of the product ID
All done!
Reference
htaccess manual
htaccess guide