PDA

View Full Version : Help with Code


Parker Clack
05-23-2006, 01:55 PM
I am wanting to display a profile field in the user.php file in the admincp directory.

Currently the code to pull the data from the table is

$users = $db->query_read("
SELECT userid, username, email, ipaddress
FROM " . TABLE_PREFIX . "user
WHERE usergroupid = 4
ORDER BY username
");


What would I change this to so it also pulls data from the userfield for that userid?

Thanks.

amykhar
05-23-2006, 02:05 PM
$users = $db->query_read("
SELECT user.userid, user.username, user.email, user.ipaddress,userfield.*
FROM " . TABLE_PREFIX . "user as user
LEFT JOIN ".TABLE_PREFIX."userfield ON user.userid=userfield.userid
WHERE usergroupid = 4
ORDER BY username
");


That's roughly it. You may need to tinker and adjust syntax. I wrote it cold.

Parker Clack
05-23-2006, 02:28 PM
Thanks.

Worked like a charm.

amykhar
05-23-2006, 02:34 PM
No problem. :)