The way you are creating the catalog pages is an inefficient use of a a database.
When suing a database, you don't need to create a separate page for each product, instead, you would create a results page that lists all products, and a details page to show the details of a specific product.
The Results page would have a link to the details page, and would pass the Product ID as a URL variable to tell the details page what product to show, for example:
product_details.php?ID=23
the recordset on the details page would be set up to filter the table based on the ID URL Variable:
for example
SELECT * FROM products WHERE productID = paramID
Variable:
Name: paramID
Type: Integer
Default Value: -1
Runtime Value: $_GET['ID']
The where clause on the recordset would return only the requested product.
In the way you have the pages created, you are creating a separate page for each product, but the recordset on each page does not have a where clause to tell the database which product it should return. This is causing the add to cart button to return the first product each time. if you do it this way, you need to explicitly tell the recordset which product record to return.
Edit the recordset on each page, in the filtering section, select the ID column and set the filter to 'Equals' 'Entered Value' and enter the ID number for the product to return.
For more details on creating a dynamic product catalog, we have some tutorial you may find helpful:
Getting Started With MySQL And Dynamic WebSites
Create a product catalog