Now you look at it, the reason it's not working is there in Technicolor®
<?php
$subcat = mysql_query("SELECT name, id FROM categories
WHERE parent_id = '$catid' ");
while ($subcatrow = mysql_fetch_array($subcat))
{
echo "<a href=\"http://localhost/template.php?catid=".$subcatrow["id"]."\">" . $subcatrow["name"] . "</a><br>";
}
?>
With a judicious use of different kinds of quotes we can be a wee bit tidier:
<?php
$subcat = mysql_query("SELECT name, id FROM categories
WHERE parent_id = '$catid' ");
while ($subcatrow = mysql_fetch_array($subcat))
{
echo '<a href="http://localhost/template.php?catid='.$subcatrow['id'].'">'.$subcatrow['name'].'</a><br>';
}
?>
Or:
<?php
$subcat = mysql_query("SELECT name, id FROM categories
WHERE parent_id = '$catid' ");
while ($subcatrow = mysql_fetch_array($subcat))
{
?><a href="http://localhost/template.php?catid=<?php echo $subcatrow['id']?>"><?php echo $subcatrow['name']?></a><br><?php
}
?>
Or:
<?php
$subcat = mysql_query("SELECT name, id FROM categories
WHERE parent_id = '$catid' ");
while ($subcatrow = mysql_fetch_array($subcat))
{
echo "<a href=\"http://localhost/template.php?catid=$subcatrow[id]\">$subcatrow[name]</a><br>";
}
?>
Whichever is easiest for you.