Accessing CB Fields in Latest News module

18 years 2 weeks ago #10407 by doomla
Hi I'm fairly new to CB. I have a need to display the value of some CB fileds with in my modded Latest News module. I need to display the value of the the current user's "Scub Experience" field ("none", "1 year", "2 years", etc.) at the top of the article. Can I access the custom fields in CB just by using "my.scub_exp" in the Latest News module in Mambo?

Please Log in to join the conversation.

18 years 2 weeks ago #10415 by mikko
you can access the fields only through databse. they are stored in #__comprofiler table.

-mikko

Please Log in to join the conversation.

18 years 2 weeks ago #10461 by doomla
Thanks, is this how its done?..

<? include "/link/to/db.inc";

$db = mysql_connect($dbhost,$dbuser,$dbpass) or die ("Unable to connect to the server. ".mysql_error());

mysql_select_db($dbname) or die ("Unable to connect to the database. ".mysql_error());

$result = mysql_query("SELECT * FROM mos_comprofiler, mos_users",$db);

$myrow = mysql_fetch_array($result) or die ("Unable to execute. ".mysql_error());

$tourPref = $myrow["tourPref"];
%>

Please Log in to join the conversation.

18 years 2 weeks ago #10485 by mikko
Two thing that are wrong here.

1) You are much better off by using joomla database API. See www.joomla.org for documentation and any piece of source code for examples.

2) You need to have "where" in your sql. Someting like "where id=$my->id"

-Mikko

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 1.679 seconds

Facebook Twitter LinkedIn