If I understand your problem, you are only lacking the passing of one more variable to the php code. On your href line, you can pass the variable using the ? as a separator. You can also pass multiple variables by separating them with the & symbol:
Code:
<a href="category{ $categories[cat_num].categoryid }.php?cat={$categories[cat_num].categoryid }">
You will then need to do something with $cat within your category1.php file, if you only want to pass it to the called tpl file, then you can do a smarty assign:
Code:
$smarty->assign("cat",$cat);
Before you make your call to the tpl. Let me know if I am not understanding your question.