Forums

Help with DB Multi Record Loader

nicholashg 12 Apr, 2011
I'm having trouble creating the custom code element to display a list of records. An example of any kind would be very useful to see where I might be going wrong.
GreyHead 12 Apr, 2011
Hi Nick,

Please post the code you are currently testing.

Bob
nicholashg 12 Apr, 2011
Hi Bob,
I know this one is just wrong and just specifying literals, but I have been round the houses!
Apologies for my lack of php understanding.
<?php
$x=array('[fname]','[lname]');
foreach ($x as $value)
  {
  echo $value . "<br />";
  }
?>

I'm calling records using this WHERE statement (which I think is correct):
<?php
$user =& JFactory::getUser();
$user_id = $user->id;
?>
`cf_user_id` = '<?php echo $user_id; ?>'

Thanks, Nick
Max_admin 15 Apr, 2011
Hi Nick,

Your WHERE code looks ok to me and should load the records submitted by the current logged in user only.

What do you have in the "Model ID" field in the "Multi record loader" settings ? I will assume that you have "Details"

To check if the data is loaded you may use this code in the "custom code" element (or even a custom code action"

print_r2($form->data);


If your WHERE statement loads any record then you should find the loaded data under the Mdel ID key which is "Details", if this works fine then you may show me a screenshot for the output and I can tell you how to loop through them.

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
nicholashg 22 Apr, 2011
Max,
I've had a week away but thank you so much for your help - things seem to be going in the right direction.
I am now displaying a series of Arrays as below and this is the data I would expect to see. So how to loop through them and achieve a simple list?

Array
(
    [Itemid] => 553
    [option] => com_chronoforms
    [view] => form
    [Details] => Array
        (
            [0] => Array
                (
                    [fname] => Nigel
                    [lname] => Johnson
                    [published] => 0
                )

            [1] => Array
                (
                    [fname] => Nicholas
                    [lname] => Peterson
                    [published] => 0
                )

            [2] => Array
                (
                    [fname] => Denis
                    [lname] => Piper
                    [published] => 0
                )

            [3] => Array
                (
                    [fname] => Penelope
                    [lname] => Garner
                    [published] => 0
                )

        )

)


This is actually just a test device so I can learn how things can be made to work - my real data is rather more complicated. It still seems to be a long way from what I was able to achieve with Chronoconnectivity but I'm hoping that I can get there step by step - when I do, I'll write a tutorial!

Nick
Max_admin 27 Apr, 2011
Hi Nick,

No problems, I was off for a few days too!🙂

Here is a simple loop:

<?php
foreach($form->data['Details'] as $detail){
echo $detail->fname;
echo '<br />';
}


That should show a list of all first names.

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
nicholashg 27 Apr, 2011
Thank you! Nearly worked - after a bit of tinkering I arrived at the following:
<?php
foreach($form->data['Details'] as $detail){
echo $detail['fname']." ".$detail['lname'];
echo '<br />';
}
?>
Max_admin 29 Apr, 2011
Oh, sorry, I forgot that the data is inside an array but not an object 😶

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.