I've left out the user table as this info is already available in $vbulletin->userinfo, so the JOIN is avoided -> lighter query.
PHP Code:
<?php
if ($vbulletin->userinfo['usergroupid']==6)
{
$result = $vbulletin->db->query_read("SELECT * FROM test WHERE test_ID = " . $vbulletin->userinfo['userid']);
while ($row = $vbulletin->db->fetch_array($result))
{
echo $row['test_name'];
}
}
?>
Also, if there is only one record for ewach userid it could be simpilified to
PHP Code:
<?php
if ($vbulletin->userinfo['usergroupid']==6 )
{
$row = $vbulletin->db->query_first("SELECT * FROM test WHERE test_ID = " . $vbulletin->userinfo['userid']);
echo $row['test_name'];
}
?>