Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

mysql Problem, new to smarty

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
haradeep
Smarty n00b


Joined: 08 May 2014
Posts: 1

PostPosted: Thu May 08, 2014 12:58 am    Post subject: mysql Problem, new to smarty Reply with quote

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
View user's profile Send private message Send e-mail
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP