Customizing SMF > SMF Coding Discussion

Profile information linking to secondary database

(1/1)

KarmicStigmata:
SMF Version:  SMF 2.0.2

Assistance with:  I am needing assistance linking a profile field (custom) to the information in a separate mySQL database.  It needs to be from the current session they are in so it would auto-populate the SMF_Callsign in the code below with the Call Sign field from the custom field in their profile.  From there I can code what I need to code for a php display.  I need that specific VARIABLE in order to do what I have to do... -.-


--- Code: ---$con = mysql_connect("localhost","username","password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("my_db", $con);

$result = mysql_query("SELECT * FROM Roster WHERE Callsign='SMF_Callsign");

--- End code ---

Edit:  IF it would make it easier to add the custom field(s) to the profile that is fine too, I still need to know how to access those fields for additional coding. I.e

$Variable1 = $profilefield1;
$Variable2 = $profilefield2;

$Variable3 = $Variable1 + $Variable2;

etc... Its for a roster system that is based on forum information / the database...

KarmicStigmata:
Solved this on my own. 

Suki:
May be worth to post your solution so other members can benefit from it.

KarmicStigmata:
Ironically, Suki, your the one I found the answer from:

global $user_info, $memberContext;

loadMemberData($user_info['id']);
loadMemberContext($user_info['id'], true);

$custom_profiled_filed = $memberContext[$user_info['id']];

Navigation

[0] Message Index

Go to full version