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

foreach array issue

 
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
monkey_boy
Smarty n00b


Joined: 11 Jan 2004
Posts: 2

PostPosted: Sun Jan 11, 2004 5:34 pm    Post subject: foreach array issue Reply with quote

Hi there,

Looking for a helping hand.

tpl:


Code:
{foreach from=$group item=group}
{$group.name}<br>
{foreach from=$group item=faq}
{$faq.title}<br>
{/foreach}
{/foreach}


php:

Code:
conn();
mysql_select_db(DB);
$sql = "SELECT $tablename1.*, $tablename.* FROM $tablename1, $tablename where $tablename1.cat = $tablename.id";
// get all the data from the table
$res = mysql_query($sql);
$results_grouped = array();
while (list($id, $title, $text, $id, $cat, $name) = mysql_fetch_array($res)) {
$results_grouped[$cat][$id] = array (
'id' => $id,
'title' => $title,
'text' => $text,
'id' => $id,
'cat' => $cat,
'name' => $name);
}

$smarty->assign('group', $results_grouped);


I would like the 'name', the name of the category, displayed as the heading.

At present all i can get it to do is display the key:

1
What types of games machine do you support?
This is a test

2
This is another test
xfgsd
sdfsdfsdfs

when what i want is:

General
What types of games machine do you support?
This is a test

Technical
This is another test
xfgsd
sdfsdfsdfs

Help would be much appreciated.
Back to top
View user's profile Send private message
monkey_boy
Smarty n00b


Joined: 11 Jan 2004
Posts: 2

PostPosted: Sun Jan 11, 2004 6:02 pm    Post subject: Reply with quote

Silly me, it was a simple error. Sure you will spot it. All sorted now.
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