Reputation: 10007
I have the following PHP to create a list of categories in Smarty.
$result_categories = $con->query("SELECT * FROM categories WHERE u_id='$blog_user[id]'");
$list_categories=array();
while ($row_categories = $result_categories->fetch_assoc())
{
$list_categories[]=$row_categories;
}
I want to make a template variable to get the proper link of a category. For example http://domain.com/username/category.php?id=*CAT_ID*
as {$Variable}
or {$row_categories.variable}
(after what`s most appropriate)
How can i manage this? Thanks in advance.
Upvotes: 0
Views: 221
Reputation: 630
If I understood you correctly, you can try the following:
while ($row_categories = $result_categories->fetch_assoc())
{
$list_categories[]=$row_categories;
$info_smarty->assign('variable',$list_categories); //or however you assign your variables
}
And in your smarty template you can call only 1 link:
{$variable[0]}
Or every link:
{foreach item=links from=$variable}
{$links}
{/foreach}
Upvotes: 1