On 26 May, Sam Grinstead wrote:
> I've not worked with php or midgard before, and I have a pretty
> basic question on loops. How do you imbed one loop in another? I want
> to display the information in a tree with each of the topic names followed
> by the articles in that topic. These two display all the topics, then all
> the names.
You simply add the second loop within the first.
Here's an example:
<?php
$topic = mgd_list_topics(354);
if ($topic) {
for ($i = 0; $i < 25 && $topic->fetch(); $i++) {
/* We're inside the topic listing for loop now */
?>
<strong>&(topic.name);</strong><br>
<?php
$article = mgd_list_topic_articles($topic->id);
if ($article) {
/* I'm using 'while' here but a 'for' loop
would work as well */
while ($article->fetch()) {
?>
&(article.title);<br>
&(article.abstract);<br>
<?php
}
}
}
}
?>
Hopefully this helps.
> Sam
/Bergie
--
-- Henri Bergius -- +358 40 525 1334 -- [EMAIL PROTECTED] --
http://www.iki.fi/Henri.Bergius
--
This is The Midgard Project's mailing list. For more information,
please visit the project's web site at http://www.midgard-project.org
To unsubscribe the list, send an empty email message to address
[EMAIL PROTECTED]