Okay here is the problem:
$result = mysql_query("SELECT * FROM products") or die("SELECT Error: ".mysql_error());
while ($a_row=mysql_fetch_array($result))
print "<table width=200 border=1>\n";
Above you have started a while statement correct?
Now right after the while statement you have the print line. That line is executed as long as your while statement holds true. Then you have the following line after the print statement:
while ($a_row=mysql_fetch_array($result))
Now this is the same while loop. You see the mistake? You are running the same loop twice. The first time you run the loop you run it on only the
following line:
print "<table width=200 border=1>\n";
That is why you get a loop of tables.
To correct your problem just delete the first while loop.
In the end your code should look like this:
<?php
$db="products";
$link = mysql_connect("localhost") or die("Couldn't connect to MySQL");
mysql_select_db($db , $link) or die("Couldn't open $db: ".mysql_error());
$result = mysql_query("SELECT * FROM products") or die("SELECT Error: ".mysql_error());
print "<table width=200 border=1>\n";
while ($a_row=mysql_fetch_array($result))
{
print "<tr>\n";
print "\t<td><a href=details.php?id=" . $a_row["id"] . ">" . $a_row["title"] . "</a>\n</td>\n";
print "</tr>\n";
}
print "</table>\n";
?>