Forums

Insert in Dropdown data from table by ID user

djobang 09 Dec, 2014
Hello,
I'm developing a form with a external database. The primary key is id ,but we have another field, fio

How i can view in dropdown data from table, colume name fio by user ID?

Than i insert custom code i view this code how text in my form from site



<?php
$form = JFactory::getDbo();
$user = JFactory::getUser();
 
$query = $db->getQuery(true);
$query= 'SELECT * FROM #__sotrudniki WHERE id='. $user->get("id");
$form->setQuery($query);
$form->query();
?>


I insert this code on DB Read on found in custom code. In Dropdown, dynamyc data Path data = ID model BD read

May be i can make it by standart option....

On screen my options

Thanks a lot.
Max_admin 10 Dec, 2014
1 Likes
Hi,

In the "conditions" box of the "db read" you should use the following code to return the table rows of the logged in user's id:

<?php
$user = JFactory::getUser();
return array("user_id" => $user->id);


Please clear the "Fields" box.

Then you can use "fio" in the "text" and "value" boxes of your dropdown "Dynamic data" tab!

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
webkruter 11 Dec, 2014
But i have problem . Code in contidion dont work. See me how text

[URL=http://www.radikal.ru][IMG]http://s51.radikal.ru/i131/1412/23/87af4654d939.png[/IMG][/URL]

[URL=http://radikal.ru/fp/d2e71ca93f694235931644ad8bd33969][IMG]http://s020.radikal.ru/i700/1412/89/17f7802dc4f4t.jpg[/IMG][/URL]
webkruter 13 Dec, 2014
Plz help. I see code from condition bd read how tex, but this code is work. How delete this code-text over code

But i have problem .. See me how text

[URL=http://www.radikal.ru][IMG]http://s51.radikal.ru/i131/1412/23/87af4654d939.png[/IMG][/URL]

[/URL]

Max_admin 15 Dec, 2014
Its because you have a space in the PHP start tag, it should be <?php

Sorry for the late answer!

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.

VPS & Email Hosting 20% discount
hostinger