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

Two dimensional query

 
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
hiteshb
Smarty Rookie


Joined: 10 Jul 2010
Posts: 11

PostPosted: Sat Feb 05, 2011 4:05 am    Post subject: Two dimensional query Reply with quote

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
View user's profile Send private message
hiteshb
Smarty Rookie


Joined: 10 Jul 2010
Posts: 11

PostPosted: Sat Feb 12, 2011 10:50 am    Post subject: Reply with quote

Waiting for help. Very Happy
Back to top
View user's profile Send private message
Aristophan
Smarty Regular


Joined: 10 Jan 2011
Posts: 96

PostPosted: Sat Feb 12, 2011 2:30 pm    Post subject: Reply with quote

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. Wink

So I just guess
Code:
SELECT * FROM table WHERE name=$givenstring

or
Code:
SELECT ifsc,branch FROM table ORDER BY name
Back to top
View user's profile Send private message
hiteshb
Smarty Rookie


Joined: 10 Jul 2010
Posts: 11

PostPosted: Sun Feb 13, 2011 8:16 pm    Post subject: Reply with quote

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
View user's profile Send private message
hiteshb
Smarty Rookie


Joined: 10 Jul 2010
Posts: 11

PostPosted: Mon Feb 14, 2011 10:54 am    Post subject: Reply with quote

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
View user's profile Send private message
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