The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
database output and <select> box?
Trying to put my database output in a <select></select> box. Any ideas how to do it in the template?
I can have the var in php in either an array or in a single variable with all the data in it. |
#2
|
|||
|
|||
With the data in an array you should be able to use the vb:each tag, like the example at the end of this article: https://vborg.vbsupport.ru/showthread.php?t=221560 (you can also search your templates for vb:each and find other examples).
|
#3
|
|||
|
|||
Code:
$chan = mysql_query("SELECT * FROM channels ORDER BY chan ASC", $connection); while ($list = mysql_fetch_array($chan)) { $var1 = $list['chan1']; } $templater-register('var1', $var1); <vb:each from="list" value="chan"> <td><select name="cGID" size="1"><option value="{vb:raw list.chan}">{vb:raw list.chan}</option></select></td> </vb:each> |
#4
|
|||
|
|||
I haven't actually used vb:each before, but I think you'd want this:
Code:
<td><select name="cGID" size="1"> <vb:each from="var1" value="chan"> <option value="{vb:raw chan}">{vb:raw chan}</option> </vb:each> </select></td> Of course as an alternative, you could do this: Code:
$menu = '<select name="cGID" size="1">'; $chan = mysql_query("SELECT * FROM channels ORDER BY chan ASC", $connection); while ($list = mysql_fetch_array($chan)) $menu .= '<option value="' . $list['chan1'] . '">' . $list['chan1'] . '</option>'; $menu .= '</select>'; $templater-register('menu', $menu); <td>{vb:raw menu}</td> |
#5
|
|||
|
|||
Code:
$chan = mysql_query("SELECT * FROM channels ORDER BY chan ASC", $connection); while ($list = mysql_fetch_array($chan)) { $chanList .= $list['gid']."<br />"; $chanGid .= $list['chan']."<br />"; $chanAcc .= $list['access']."<br />"; $zlist.= "<option value='".$list['gid']."'>".$list['gid']."</option>"; } then.. $templater->register('zlist',$zlist); then in the template.. <select name="derp" size="2">{vb:raw zlist}</select> |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|