Forums

Reopen - DB record loader , user field

Invidia 21 Feb, 2012
Hello,

I also have trouble to load the name of the user out of the database.
I have a table where every user will have a row.

But I'am not able to load the name in the text field.

1. What should I use ?
- DB Record Loader or
- DB Multi Record Loader

2. If you leave DB Field empty, will all fields load if I only define the user in the query.
I tried to put spelersnaam (field of the usernames in database) in DB Field, also without.
3. The biggest problem what to put in WHERE statement. I already tried:
<?php
$user = &JFactory::getUser();
echo $user->username;
?>

and
<?php
$user->get('username');
echo " `username` = $user ";
?>


I already had this error in my log:

- PHP Notice: Undefined variable: user in /var/www/amtest/administrator/components/com_chronoforms/form_actions/db_multi_record_loader/db_multi_record_loader.php(275) : eval()'d code on line 2, referer: http://am.****.be/index.php?option=com_content&view=article&id=12&Itemid=117
- PHP Fatal error: Call to a member function get() on a non-object in /var/www/amtest/administrator/components/com_chronoforms/form_actions/db_multi_record_loader/db_multi_record_loader.php(275) : eval()'d code on line 2, referer: http://am.****.be/index.php?option=com_content&view=article&id=12&Itemid=117
GreyHead 21 Feb, 2012
Hi Invidia,

Use the DB Record Loader if you want to load one record only

Use the DB Multi Record Loader if you want to load more than one record.

The correct syntax for the WHERE box will be something like
<?php 
$user =& JFactory::getUser();
echo "`some_column_name` = '{$user->name}'";
?>


Bob
Invidia 23 Feb, 2012
Everything just works fine, except this.

How te exclude a field from being loaded. This is for a hidden field with a php written default value.

Thanks for the great work and support.
GreyHead 23 Feb, 2012
Hi Invidia,

Hmm, I think use a Custom Code action to unset the value you don't want. This has to be after the the DB Recod Loader and before the Show HTML action.

Or, you could give the hidden input a different name and rename it after the form is submitted.

Or, perhaps better, don't use a hidden input at all but use a Custom Code action after the form is submitted to set the default value.

Bob
Invidia 23 Feb, 2012
A little more in detail:

When I created the table, chronoforms did create a field cf_ipaddress.
This works for every new input, but doesn't change anymore on update. I activated the hidden field with cf_id as name (for updated fields).
So if I load the ipfield again. It will not be updated because he load's the old ip.
The users should not change the ip themselves.

Thanks for the quick response !
This topic is locked and no more replies can be posted.