Forums

Multi read - Display

U Can Drive 13 Feb, 2016
I am using a unique identifier (license number) to retrieve student files rather than their names which in rare circumstances could be duplicated.

I want to create a form that will tell me the students license number when I put their name in. As the name has a rare potential of having a duplicate I'm using the "Multi Read" function.

How do I display more than one record?
GreyHead 13 Feb, 2016
Hi U Can Drive,

I'd probably use a Custom Code element and use a loop to read and display the records from the data array.

Bob
GreyHead 13 Feb, 2016
Hi U Can Drive,

Please drag a Debugger action into the On Load event, then submit the form and post the debug results here.

Bob
U Can Drive 13 Feb, 2016
Debug Info:

Array
(
    [11] => Array
        (
            [DB Read] => Array
                (
                    [Queries] => Array
                        (
                            [0] => SELECT `SData`.`id` AS `SData.id`, `SData`.`uniq_id` AS `SData.uniq_id`, `SData`.`user_id` AS `SData.user_id`, `SData`.`created` AS `SData.created`, `SData`.`modified` AS `SData.modified`, `SData`.`Name` AS `SData.Name`, `SData`.`License` AS `SData.License`, `SData`.`Email` AS `SData.Email`, `SData`.`Mobile` AS `SData.Mobile`, `SData`.`Phone` AS `SData.Phone`, `SData`.`Birth` AS `SData.Birth`, `SData`.`Effective` AS `SData.Effective`, `SData`.`Expiry` AS `SData.Expiry`, `SData`.`Class` AS `SData.Class`, `SData`.`Type` AS `SData.Type`, `SData`.`Conditions` AS `SData.Conditions`, `SData`.`Address` AS `SData.Address`, `SData`.`School` AS `SData.School`, `SData`.`Work` AS `SData.Work`, `SData`.`Paid` AS `SData.Paid`, `SData`.`Completed` AS `SData.Completed`, `SData`.`Cancelled` AS `SData.Cancelled`, `SData`.`NoShow` AS `SData.NoShow`, `SData`.`TestBook` AS `SData.TestBook`, `SData`.`LessonHire` AS `SData.LessonHire`, `SData`.`Years` AS `SData.Years`, `SData`.`Defensive` AS `SData.Defensive`, `SData`.`Logged` AS `SData.Logged`, `SData`.`Observation` AS `SData.Observation`, `SData`.`Read` AS `SData.Read`, `SData`.`Signs` AS `SData.Signs`, `SData`.`Speed` AS `SData.Speed`, `SData`.`Clutch` AS `SData.Clutch`, `SData`.`Gears` AS `SData.Gears`, `SData`.`Lights` AS `SData.Lights`, `SData`.`Round` AS `SData.Round`, `SData`.`Position` AS `SData.Position`, `SData`.`Preperation` AS `SData.Preperation`, `SData`.`Hill` AS `SData.Hill`, `SData`.`UTurn` AS `SData.UTurn`, `SData`.`Around` AS `SData.Around`, `SData`.`Reverse` AS `SData.Reverse`, `SData`.`PPark` AS `SData.PPark`, `SData`.`Gear` AS `SData.Gear`, `SData`.`LessonID` AS `SData.LessonID`, `SData`.`Supervisor` AS `SData.Supervisor`, `SData`.`SLicense` AS `SData.SLicense`, `SData`.`SEmail` AS `SData.SEmail`, `SData`.`SMobile` AS `SData.SMobile`, `SData`.`Feedback` AS `SData.Feedback`, `SData`.`Comments` AS `SData.Comments` FROM `UCD_StudentRegistration` AS `SData` WHERE `SData`.`Name` = 'First Last'
                        )

                )

        )

)
U Can Drive 13 Feb, 2016
In case it's helpful (or I got the wrong one), you'll notice I've set up two test accounts with the same name but different license numbers. I'm using "Name" to find multiple "License" returns.
Data Array:

Array
(
    [option] => com_chronoforms5
    [chronoform] => LicenseRequest
    [event] => submit
    [StudentsName] => First Last
    [id] => 
    [button2] => Submit
    [License] => 
    [e87d58a2f4710c047ff9002df0d554de] => 1
    [0] => Array
        (
            [id] => 72
            [uniq_id] => 82caf23a5517eb24add685b978e2adda847fac95
            [user_id] => 1065
            [created] => 2016-02-13 16:24:06
            [modified] => 2016-02-13 18:14:04
            [Name] => First Last
            [License] => 123456789
            [Email] => test@testing.com
            [Mobile] => 0414555252
            [Phone] => 0746131415
            [Birth] => 09/02/1975
            [Effective] => 01/01/2001
            [Expiry] => 31/12/2020
            [Class] => C
            [Type] => L
            [Conditions] => -
            [Address] => 0/0 Home St,
Suburb
            [School] => School
            [Work] => Work
            [Paid] => 5
            [Completed] => 1
            [Cancelled] => 1
            [NoShow] => 0
            [TestBook] => 0
            [LessonHire] => 0
            [Years] => 3
            [Defensive] => 1
            [Logged] => 0
            [Observation] => 4
            [Read] => 3
            [Signs] => 5
            [Speed] => 3
            [Clutch] => 3
            [Gears] => 4
            [Lights] => 4
            [Round] => 4
            [Position] => 4
            [Preperation] => 
            [Hill] => 4
            [UTurn] => 3
            [Around] => 2
            [Reverse] => 1
            [PPark] => 0
            [Gear] => 0
            [LessonID] => 
            [Supervisor] => 
            [SLicense] => 
            [SEmail] => 
            [SMobile] => 
            [Feedback] => You did very well today however you are still stalling occasionally but not on the hill start which is a bit unusual. I suspect it is because you are concentrating more on what you are doing on a hill than you are in a general driving situations.
 I recommend that you practice just driving for a while trying to get that clutch working on a more regular basis.
            [Comments] =>  I find first last to be a confident driver but needs to focus on what they are doing  rather than expecting it to  just work.
        )

    [1] => Array
        (
            [id] => 75
            [uniq_id] => 877325dd0cd3f08a6c2e0397a7215e35aab97547
            [user_id] => 1065
            [created] => 2016-02-13 16:37:09
            [modified] => 2016-02-13 17:21:54
            [Name] => First Last
            [License] => 987654321
            [Email] => testing@test.com
            [Mobile] => 0414555525
            [Phone] => 0746123456
            [Birth] => 03/11/1978
            [Effective] => 01/01/2000
            [Expiry] => 31/12/2020
            [Class] => C
            [Type] => L
            [Conditions] => -
            [Address] => 0/0 Home St,
Suburb
            [School] => School
            [Work] => Work
            [Paid] => 00
            [Completed] => 00
            [Cancelled] => 00
            [NoShow] => 00
            [TestBook] => 0
            [LessonHire] => 0
            [Years] => 0
            [Defensive] => 0
            [Logged] => 0
            [Observation] => 00
            [Read] => 00
            [Signs] => 00
            [Speed] => 00
            [Clutch] => 00
            [Gears] => 00
            [Lights] => 00
            [Round] => 00
            [Position] => 00
            [Preperation] => 
            [Hill] => 00
            [UTurn] => 00
            [Around] => 00
            [Reverse] => 00
            [PPark] => 00
            [Gear] => 00
            [LessonID] => 
            [Supervisor] => 
            [SLicense] => 
            [SEmail] => 
            [SMobile] => 
            [Feedback] => 
            [Comments] => 
        )

)
GreyHead 13 Feb, 2016
Hi U Can Drive,

Hmm - the data should be showing up in the SData sub array and it isn't. I'm not clear why.

If you only need a few columns then select only those in the DB Read action.

Bob
U Can Drive 13 Feb, 2016
I have shrunk the data down:

Array
(
    [option] => com_chronoforms5
    [chronoform] => LicenseRequest
    [event] => submit
    [StudentsName] => First Last
    [id] => 
    [button2] => Submit
    [License1] => 
    [License2] => 
    [eb18c899781ba8755dbb4f266715c993] => 1
    [0] => Array
        (
            [Name] => First Last
            [License] => 123456789
        )

    [1] => Array
        (
            [Name] => First Last
            [License] => 987654321
        )

)

The debug:
Array
(
    [11] => Array
        (
            [DB Read] => Array
                (
                    [Queries] => Array
                        (
                            [0] => SELECT `SData`.`Name` AS `SData.Name`, `SData`.`License` AS `SData.License` FROM `UCD_StudentRegistration` AS `SData` WHERE `SData`.`Name` = 'First Last'
                        )

                )

        )

)


It's getting the information I need, the form has two display options for the License return.

I guess all I need is something like:
<?php
$form->data['License1'] = ???
$form->data['License2'] = ???
?>
to fill the two boxes with the info from array 0 & array 1. I just don't know how to do this ???

Do I need to fill something into the Order and/or Group options as well?
GreyHead 13 Feb, 2016
Hi U Can Drive.

Pleas post a screen shot of the DB Read settings ( or PM me the site URL, the form name, and a SuperAdmin login ) I need to try to work out why the Records are not being put into $form->data['SData']

Bob
U Can Drive 15 Feb, 2016
Thank you, I have PM'ed you.
U Can Drive 22 Feb, 2016
Have uploaded the DB Read screen capture. Really would appreciate your help.
GreyHead 23 Feb, 2016
Answer
Hi U Can Drive,

Sorry for the delay. I think it is working now. I have added this Custom code to copy the values into the variable names you need.
<?php
foreach ( $form->data['SData']  as $k => $v ) {
  if ( $k < 1 ) {
    $form->data['License'] = $v['License'];
  } else {
    $form->data['License'.$k] = $v['License'];
  }
}
?>

Bob
U Can Drive 23 Feb, 2016
Thanks again GreyHead.

Your help is much appreciated, have a coffee on me, I'm sure you could use the caffeine!
This topic is locked and no more replies can be posted.