TEMA:

Populate Field with Data from DB 1 año 5 meses antes #267232

  • Autor del tema
  • papin0
  • Fuera de línea
  • Navegador Experto
  • Navegador Experto
  • Registered
  • Mensajes: 208
  • Gracias recibidas: 0
My code is working but it only bring the data of one user instead of the login user
//Get Badge Number
$this->execPieceByName('ff_InitLib');
$db = JFactory::getDBO();
$userid = JFactory::getUser()->id;
$db->setQuery('SELECT value FROM #__fields_values WHERE field_id=1');
$result = $db->loadResult();
ff_setValue('badge', $result);

TIA

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Populate Field with Data from DB 1 año 5 meses antes #267233

  • Avatar de Mirec
  • Mirec
  • Fuera de línea
  • Navegador Platino
  • Navegador Platino
  • Registered
  • Mensajes: 3262
  • Gracias recibidas: 163
Hi,

try like this
//Get Badge Number
$this->execPieceByName('ff_InitLib');
$db = JFactory::getDBO();
$userid = JFactory::getUser()->id;
$db->setQuery('SELECT * FROM #__fields_values
INNER JOIN #__users on #__fields_values.field_id=#__users.id
WHERE #__users.id='.$userid);
$result = $db->loadResult();
ff_setValue('badge', $result);

Let me know the result!
Regards,
Mirko

Adjuntos:

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Populate Field with Data from DB 1 año 5 meses antes #267234

  • Autor del tema
  • papin0
  • Fuera de línea
  • Navegador Experto
  • Navegador Experto
  • Registered
  • Mensajes: 208
  • Gracias recibidas: 0
Is not working,
I need to pull the user's badge number

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Última Edición: Post by papin0.

Populate Field with Data from DB 1 año 5 meses antes #267243

  • Avatar de Mirec
  • Mirec
  • Fuera de línea
  • Navegador Platino
  • Navegador Platino
  • Registered
  • Mensajes: 3262
  • Gracias recibidas: 163
Hi,

based on the code that you provided here, and you want to get info in table "__fields_values" based on logged user, for that, we need to connect table where users are stored," _users" with "__fields_values".

I really do not know why my example does didn't work, it should be great if you can send me database access info and backend link, that I can make some tests, on email ma@evolutio.hr

Did you get any errors?

Regards,
Mirko

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Última Edición: Post by Mirec.

Populate Field with Data from DB 1 año 5 meses antes #267258

  • Autor del tema
  • papin0
  • Fuera de línea
  • Navegador Experto
  • Navegador Experto
  • Registered
  • Mensajes: 208
  • Gracias recibidas: 0
I need to get the badge value not the user id
like here I get the Badge value but not for the logging user

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

Última Edición: Post by papin0.

Populate Field with Data from DB 1 año 5 meses antes #267259

  • Autor del tema
  • papin0
  • Fuera de línea
  • Navegador Experto
  • Navegador Experto
  • Registered
  • Mensajes: 208
  • Gracias recibidas: 0
Este mensaje contiene información confidencial

Por favor, Identificarse o Crear cuenta para unirse a la conversación.

  • Página:
  • 1
  • 2
Moderadores: ForumSupport
Tiempo de carga de la página: 0.064 segundos

Live Support Chat Opened!

Join our Discord chat here and enter the Crosstec channels to receive live support and talk directly to the team!