You could do something like this:
Code:
$result = $vbulletin->db->query("SELECT userfield.fieldX, userfield.userid FROM userfield INNER JOIN user ON user.userid =userfield.userid WHERE usergroupid IN (list_of_usergroups)");
$rendered_table = '<table>';
while ($row = $vbulletin->db->fetch_array($result))
{
$rendered_table .= '<tr><td>' . $row['userid'] . '</td><td>' . $row['fieldX'] . '</td></tr>';
}
$rendered_table .= '</table>';
vB_Template::preRegister('template_name', array('rendered_table' => $rendered_table));
then use {vb raw rendered_table} in the template. (This assumes you want to put it in an existing template. If you're creating your own template then you'd probably use register() instead of preRegister()).
Quote:
Originally Posted by vBNinja
Also once i get that working, i would normally use a foreach loop and build the table with "echo" but since i'm trying to integrate this to a vbulletin page, should i just concatenate the html in the php file and render it as a variable to use in a vb template then simply use it like: "{vb raw rendered_table}" or is there a more efficient way of doing this?
|
That's what the above example does, and there's no problem doing it that way. But I should mention that the convention in the vbulletin code is to put any html in a template and render the template. You could have a template for one table row, or you can save all the rows to an array and then use <vb:each> in the template to loop through them.