|
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 |
hiteshb Smarty Rookie
Joined: 10 Jul 2010 Posts: 11
|
Posted: Fri Sep 07, 2012 11:29 am Post subject: Need help with Smarty Multi Dimensional Array |
|
|
I am really in mess as I am unable to solve problem with Smarty Multi Dimension array.
Below is the way I want to execute Smarty.
First of all I will list all customers. Than I want list of all items purchased by that customer. I have two tables inside mysql (customer, sale). In Customer table only information related to his name and email is stored. While in sale table information related to item, price and customer is sold.
Below is the way I will execute my smarty.
John
-Item1
-Item2
-Item3
David
-Item5
-Item2
-Item7
In PHP File I have added below things.
$allcustomer = $fetchObj->getAllcustomer
$customer_name = $allcustomer['customer_name'];
$fetchObj->customer_name = $customer_name;
$allitem = $fetchObj->getAllitembycust();
$smarty->assign('allcustomer',$allcustomer);
$smarty->assign('allitem',$allitem);
In class file I am fetching content through below script for item list inside each customer
function getAllitembycust()
{
global $db,$smarty;
$sql = " SELECT * FROM sale WHERE customer_name = '$this->customer_name' ORDER BY date ASC";
$theList = $db->getAll($sql);
return $theList;
}
In .tpl file below code is their.
{foreach from=$allcustomer item=allcustomer}
{$allcustomer.customer_name}
{$allcustomer.email}
List of Item Purchased
{foreach from=$allitem item=allitem}
<ul>
<li>{$allitem.items}</li>
</ul>
{/foreach}
{/foreach}
Please help me here. |
|
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
|