|
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: Sat Feb 05, 2011 4:05 am Post subject: Two dimensional query |
|
|
First I would like to tell you that I am not PHP expert. I only know how to create queries and execute same through smarty tags.
I have class files in system directory where queries are listed.
My database is in following way.
Now, I want query to be exceuted in following way.
So in simple words, I want bank name to come only one time (distinct) and in that all its branches should be listed.
For reference, table name is bank.
Plz. help me sort out this multi dimensional problem. |
|
Back to top |
|
hiteshb Smarty Rookie
Joined: 10 Jul 2010 Posts: 11
|
Posted: Sat Feb 12, 2011 10:50 am Post subject: |
|
|
Waiting for help. |
|
Back to top |
|
Aristophan Smarty Regular
Joined: 10 Jan 2011 Posts: 96
|
Posted: Sat Feb 12, 2011 2:30 pm Post subject: |
|
|
Well it seems you are in the wrong forum. This is not a smarty question.
The question is sort of basic php, which is recommended being learned before doing PHP & MySQL stuff.
So I just guess
Code: | SELECT * FROM table WHERE name=$givenstring |
or
Code: | SELECT ifsc,branch FROM table ORDER BY name |
|
|
Back to top |
|
hiteshb Smarty Rookie
Joined: 10 Jul 2010 Posts: 11
|
Posted: Sun Feb 13, 2011 8:16 pm Post subject: |
|
|
Thanks for answer.
I am just newbie and somehow got knowledge of Smarty. Reason for choosing Smarty was to simplying PHP codes. Anyway thanks once again. |
|
Back to top |
|
hiteshb Smarty Rookie
Joined: 10 Jul 2010 Posts: 11
|
Posted: Mon Feb 14, 2011 10:54 am Post subject: |
|
|
Looks not working or I didn't got it.
Ok. Below is something I am using correct (for single dimensional)
Below is in class file.
Code: | function getAlllist()
{
global $db,$smarty;
$sql = " SELECT DISTINCT name FROM series ORDER BY name ASC";
$theList = $db->getAll($sql);
return $theList;
}
|
Below is something in my index.php file.
Code: | $alllist = $scheduleObj->getAlllist();
$smarty->assign('alllist',$alllist);
|
Below I am using to excecute in tpl file.
Code: | {foreach from=$alllist item=alllist}
{$series.name}
{/foreach} |
Now what should I do. I already done distinct. Now I want to match the name and list them under one head. This way total 10 headings covering 100 rows would be finished. |
|
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
|