I have been trying to do this for ages now and I could not find a good solution on how to do it! Smarty is making things harder for me! Nevertheless I want to show it in Smarty because all my programing are in Smarty. I looked everywhere for a solution or something similar to what I want but I could not find any, I am guessing somebody in here can give me an example of what I want or give me a code that works on the example that I am giving. Anyways, let me show you what I have:
I have a table that looks like this (table name: chapter):
date_add manga_name manga_title chapter_num
12/23/2012 One Piece OnePiece 002
12/23/2012 One Piece OnePiece 003
12/22/2012 Naruto Naru 002
in the tpl file lets say that I have this
{section name=chp loop=$chpt}
{$chpt[chp].date_add}
{$chpt[chp].manga_name}</a>
<a href="{$chpt[chp].manga_title}/{$chpt[chp].chapter_num} ">{"%03d"|sprintf:$chpt[chp].chapter_num} </a>
{/section}
which will show in this way in real life :
12/23/2012 One Piece [0002][withURL]
12/23/2012 One Piece [0003][withURL]
12/22/2012 Naruto [0002][withURL]
How I want to show it is like this :
One Piece :
0002[withURL] 12/23/2012
0003[withURL] 12/23/2012
Naruto :
0002[withURL] 12/22/2012
I tried many ways to execute it but failed! I looked for some examples and could not find any! What I need is an example that is similar to mine and how to do it with smarty! Smarty is making things harder because I do not know how to use multidimensional sections! and what to put for my MYSQL query! There is got to be a way to do it! Here is my PHP code with SQL statment:
$chapter = $db->query("SELECT date_add, manga_name, manga_title, chapter_num FROM chapter ORDER BY ch_Id DESC Limit 0,6");
while($chpt = $db->fetch_array($chapter))
{$chps[] = $chpt;}
$smarty->assign('chpt' , $chps);
This is just a sample of what I have, If you can give me a soultion for it then I can understand the rest.
Basically I want to remove duplicated manga_name results and add all the chapter_num that belongs to the manga_name under them.