loadObjectList();foreach($categories as $category) {$category=($category->anv;echo $category;}?>"anv" is the username column in my database-table. The $v_id variable stores the current id in the loop.Anyone have any suggestions?"> Access Joomla user table in CC - Forums

Forums

Access Joomla user table in CC

PicoPaco 17 Jun, 2010
Hi,

I have a CC that will display data from a table named "record". In this table I have some columns for example it stores the joomla username. I try to access the email adress in the joomla user table by using the username, but I dont get it to work. I have tried different soulutions.

This is code in the body of CC

<?php

$v_id = '{id}';

$database->setQuery( "SELECT `anv` FROM `record` WHERE `id` = $v_id" );
$categories = $database->loadObjectList();

foreach($categories as $category) {
$category=($category->anv;
echo $category;

}
?>

"anv" is the username column in my database-table. The $v_id variable stores the current id in the loop.

Anyone have any suggestions?
PicoPaco 17 Jun, 2010
The only thing I really need to find out is how to put {field} to a variable, for example:

<?php
$name = '{name}';
?>

The variable $name actually do return the value of {name} here, but I can't use the value for example an IF-statemant or to compare a WHERE-statement in sql.

Anyone knows how to do this?

Best regards
Markus
nml375 17 Jun, 2010
Hi Marcus,
From memory, you should use $MyRow->id.
Be adviced though, that performing queries of your own in the body may cause issues in some cases (sorry, don't remember the specifics, but I do belive you'll find a few threads regarding this in the forum a few months back or so).

/Fredrik
PicoPaco 18 Jun, 2010
Thanks alot Fredrik!

This helped me alot, simple thing that is hard to do if you don't know how🙂


Trevlig helg
/Markus
This topic is locked and no more replies can be posted.