Here is the code:
<META name="description" content="">
<META name="keywords" content="">
<META name="generator" content="CuteHTML">
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080">



$article = mysql_query("SELECT C.ID as CatID, C.Name as CatName, S.ID as SubID, S.Name as SubName, " .
"S.CID as SubCID FROM categories as C, subcategories as S WHERE S.CID=$id");
if (!$article) {
echo("<P>Error retrieving authors from database!<BR>".
"Error: " . mysql_error());

$title = mysql_fetch_array($article);
$titlename = $title["CatName"];
echo("<font size='5'>$titlename</font><br><br>");

while ($select = mysql_fetch_array($article)) {
$subid = $select["SubID"];
$subname = $select["SubName"];
echo("<a href='subcat.php?id=$subid'>$subname</a><br>");



basically, as you can see at:

It does really funny loops and i have no idea why. Can anyone help me out on this?