How can dynamic paths to products in a database be generated in PHP for displaying article pages?

When displaying article pages for products stored in a database, dynamic paths need to be generated in PHP to ensure each product has a unique URL. This can be achieved by using a combination of the product ID and product name to create a SEO-friendly URL structure. By dynamically generating the paths, you can easily retrieve and display the correct product information based on the URL.

// Assuming $productID and $productName are available variables from the database
$productID = 123;
$productName = "example-product-name";

// Generate the dynamic path using the product ID and name
$productPath = "/products/" . $productID . "/" . strtolower(str_replace(" ", "-", $productName));

// Display the product page with the dynamic path
echo "<a href='" . $productPath . "'>View Product</a>";