The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Loops in templates
I have to make a custom page which queries a database and gets say n rows.
I store the rows in an array. Now, i have to display the contents of each row, one line for one row. For this, i need to have a for loop in the template. How do i do this? I hope my question is clear..... |
#2
|
|||
|
|||
You can't have a loop. What you need is a second template just containing the code required for the row and then call that template in the first template.
|
#3
|
|||
|
|||
How exactly?
Look at the following code Code:
eval('print_output("' . fetch_template('template1') . '");'); $sql = $db->query_read("SELECT name FROM " . TABLE_PREFIX . "people"); while ($array = $db->fetch_array($sql)) { $name = $array["0"]; eval('print_output("' . fetch_template('template_row') . '");'); } eval('print_output("' . fetch_template('template2') . '");'); Code:
$stylevar[htmldoctype] <html dir="$stylevar[textdirection]" lang="$stylevar[languagecode]"> <head> $headinclude <title>$vboptions[bbtitle] - Submit Executive Summary for Mentoring</title> </head> <body> $header $navbar <table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center"> <tr> <td class="tcat" colspan="2">Heading</td> </tr> <tr> <td class="alt1">Name: *</td> <td class="alt1"><select name="name"> Code:
<option name="$name">$name</option> Code:
</select></td></tr></table> $footer Do i have to use $template_row in template1 ?? Please help! Stuck at this thing for the last 2 days |
#4
|
|||
|
|||
he needs a foreach command i think.
|
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|