Forums

Data from another table

brononius 07 Mar, 2013
Hey,

I'm using 'Community Builder' to build some profile data (fe address, birthday...).
And i would like to use this now in some form. That some fields are filled in with the data.

Today, it's working great for the standard username and so in a 'custom code':
<?php
$user =& JFactory::getUser();
$form->data['user_email'] = $user->email;
$form->data['user_lidnummer'] = $user->username;
$form->data['user_id'] = $user->id;
$form->data['user_naam'] = $user->name;
?>


But i would like to pull some data now from the CB tables:
Table: db_comprofiler
fiels: cb_birth, cb_street, cb_state......

Is it possible to do this?
GreyHead 07 Mar, 2013
Hi brononius,

Yes I think so, I don't use CB but there are some recent forum posts about doing this if you search for them.

Bob
brononius 07 Mar, 2013
I'm playing around with the DB Multi Record Loader...

First i load a custom code to get my user ID:
<?php
$user =& JFactory::getUser();
$form->data['user_id_get'] = $user->id;
?>


And now, with the DB Multi Record, i want to match the user_id in the table comprofiler / user_id and return the value cb_state.
BASIC > Table = db_comprofiler
ADVANCED > WHERE statement = user_id = user_id_get
DATA DISPLAYER > ENABLE = YES
DATA DISPLAYER > Display fields = cb_state


The problem is that the 'WHERE statement' isn't working like i thought it would. If I fe change the user_id_get with my ID (fe 222), it works great.


Any idea if i can solve this easily?
GreyHead 08 Mar, 2013
Hi brononius,

I think that you need curly brackets in the WHERE statement
`user_id` = '{user_id_get}'

Bob
brononius 08 Mar, 2013
He seems not to 'translate' the user_get_id...

When i enable a debugger, i'm getting:
SELECT `MagComprofiler`.* FROM `mag_comprofiler` AS `MagComprofiler` WHERE `user_id` = '{user_id_get}'
GreyHead 09 Mar, 2013
Hi brononius,

OK, then please try the PHP version:
`user_id` = '<?php echo $form->data['user_id_get']; ?>'

Bob
brononius 16 Mar, 2013
Great !!!

Works with this script...


Thanks!
This topic is locked and no more replies can be posted.