As
MoT3rror suggested, you can cover everything in the single query so you have:
PHP Code:
$username = $_GET['user'];
$sql = "SELECT user.userid, user.usergroupid, userfield.field6
FROM vb_user AS user
LEFT JOIN vb_userfield AS userfield ON (userfield.userid = user.userid)
WHERE user.username = '" . mysql_escape_string($username) . "' LIMIT 1";
$query = mysql_query($sql);
// Do our error checking first...
if(!$query)
{
echo 'Username: Invalid';
}
else
{
// Use mysql_fetch_assoc to return [field] => [value] array result
$data = mysql_fetch_assoc($query);
// Use single quotes if there are no variables in strings
echo 'Username: ' . $username .'<br>';
echo 'Userid: ' . $data['userid'] . '<br>';
echo 'Group: ' . $data['usergroupid'] . '<br>';
echo 'programid: ' . $data['field6'] . '<br>';
}
(Credit to MoT3rror for SQL)