|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
haradeep Smarty n00b
Joined: 08 May 2014 Posts: 1
|
Posted: Thu May 08, 2014 12:58 am Post subject: mysql Problem, new to smarty |
|
|
Below, I'm having problem with mysql statements,
I want to get the id value and run the second sql statement.
I tried in many ways, but unable to fetch the cat_sub.
Please Help.
Code: |
$sql2 = "select * from categories where p_id is null";
$result = mysqli_query($con, $sql2);
$id = array();
while($row2 = mysqli_fetch_array($result)){
$id[]=$row2;
$smarty->assign("id", $id);
}
$sql3 = "select * from categories where p_id = '$id'";
$result3 = mysqli_query($con, $sql3);
$cat_sub = array();
while ($row3 = mysqli_fetch_array($result3)) {
$cat_sub[]=$row3;
}
$smarty->assign("cat_sub", $cat_sub);
|
Code: |
{foreach from=$cat_sub item=n}
{$n.category}<br>
{/foreach}
|
It worked in PHP, but I'm new to smarty. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|