PDA

View Full Version : Pulling custom profile field data from MySQL dbase


TheMusicMan
03-24-2007, 06:46 AM
Hi All

Can someone help me with this one please. I am writing some code that needs to grab data from one or more Custom Profile Fields. I need to obtain this profile information from the MySQL database (obviously) and am wondering how I get it.

I see there is a profilefields table that contains details of the actual profile fields (including custom ones), but which table do I query to get at the custom profile data for a member?

Specifically, I want to be able to pull and retrieve data, then sort this data, then present this data across all (or a selection of) my member records.

How do I do this please? I know it's via a

SELECT * from table_name WHERE conditions_here_ ORDER BY etc

But what table do I query to get at the custom profile data items for a member...?

MarkPW
03-24-2007, 03:45 PM
This info will retrieve userfield info for member id: 1, using vb's db class.

$db->query_first("SELECT * FROM " . TABLE_PREFIX . "userfield WHERE userid=1");

TheMusicMan
03-24-2007, 03:58 PM
Mark - you are a great help thanks.

Can you elaborate on what the query_first bit means please and also how I then access the Custom Field Data (say in Custom Field1) from the userfield.

MarkPW
03-24-2007, 04:18 PM
query_first() executes a data-reading SQL query, returning an array of the data from the first row from the result set.

To access your custom data, you would do:


$userdata = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "userfield WHERE userid=1");

echo '<pre>';
print_r($userdata);
echo '</pre>';

echo $userdata['field1']; //and so on

TheMusicMan
03-24-2007, 04:24 PM
WOW - as easy as that eh! (when you know how)

Thanks a million Mark, very much appreciated.