Yep, you have lots of bugs in your code. What your code does right now is, that it selects only the products_categories-table when it should use all of them. You dont get $row["url"],$row["name"] and $row["imagefile"], because you didnt join the tables together.
And you dont have relative id for the products table so how do you know which category the product belongs to?
Ok, my advice is: lose the products_categories table and do the tables like this:
categories
-id
-parent_id
-name
products
-id
-cat_id
-name
-price
-url
-imagefile
Now its much better.. So now if you want to get all products which belongs to certain category, your code should be like this:
$query="SELECT categories.name,products.name as name2,price,url,imagefile FROM categories,products WHERE categories.id = '".$catid."' and categories.id = products.cat_id";
$result=mysql_query($query);
while ($row = mysql_fetch_array($result)) {
echo "<a href=\"" . $row["url"] . "\"><img src=\"" . $row["imagefile"] . "\" border=0 alt=\"" . $row["name2"] . "\"><BR>";
}
Notice that I changed the products.name to name2 because you use mysql_fetch_array and those could get mixed up in the code.