This is important and the best thing if you use post id and slug in your URL. The id should be autoincremented and the slug will be converted by the slug function.
Here, you will find the slug() function.
https://technosmarter.com/qa/585/i-want-to-make-seo-friendly-url-in-php
How to use post id and slug in post URL using PHP?
You will need to use the htaccess code to do that. You are not familiar SEO friendly URLs. You can start to learn blog system in PHP.
If you want to use post id and slug-like -
example.com/id/slug
Use htaccess code-
Create a file and save it as .htaccess
RewriteEngine on
RewriteRule ^([0-9]+)/([0-9a-zA-Z_-]+)$ single.php?id=$1&slug=$2 [QSA,L]
Change your URL like this -
example.com/123/this-is-post-slug
Change your code line like this -
<a href="<?php echo $row['id']; ?>/<?php echo $row['slug']; ?>"><h2><?php echo $row['title']; ?></h2></a>
or if you want a single word in your URL then create .htaccess code like this -
RewriteEngine on
RewriteRule ^single/([0-9]+)/([0-9a-zA-Z_-]+)$ single.php?id=$1&slug=$2 [QSA,L]
Now, the URL should be like this -
example.com/single/123/this-is-slug
or if you use a single word in your URL then PHP code line will be like -
<a href="single/<?php echo $row['id']; ?>/<?php echo $row['slug']; ?>"><h2><?php echo $row['title']; ?></h2></a>
These are examples of SEO-friendly URLs in PHP. In this way, you can get id and slug value on your page and display related content.
Like -
$id=$_GET['id'];
$slug=$_GET['slug'];
You can use id or slug to fetch data from the database and display it on your page.