November 20, 200817 yr hello.. (thanks for your help with related fields, prev posts) i have a calculated URL field that includes a random, alpha numeric string, uniquely identifying a meeting attendee. This URL is part of an email invitation each attendee receives. I'd like prospective attendee to click the link and be taken to 'form.php' AND looking at their record (which will have been partially completed in advance). Something like: "http://server/form.php?Attendee_ID=" & Attendee_ID i can make this work by substituting "recid" for "Attendee_ID", but that's not alphanumeric, nor is it random. I don't people trying out different recid's and viewing other records. i used to do this in CDML, but don't know the equivalent in PHP? thanks in advance brian
November 20, 200817 yr Could you elaborate a little more on exactly what isn't working when you attempt to retrieve a record based on passing Attendee_ID via the URL? example code is always helpful
November 20, 200817 yr Author sorry.. here's what i'd started with, based on jon starks' book: $attendee = $fm->getRecordById('table', $_GET['recid']); in filemaker.. the calc for the URL becomes: "http://server/form.php?recid=" & recid this works.. but what i want is to use my "Attendee_ID" field instead of "recid". But then i can't use 'getRecordByID'. I imagine there is some function like: $attendee = $fm->FUNCTION('table', $_GET['Attendee_ID'] "FUNCTION" is what i'm looking for..
November 20, 200817 yr OK so you need to know how to perform a find with the API. $findreq = $fm->newFindCommand("layout_name"); $findreq->addFindCriterion("Attendee_ID", $_GET['Attendee_ID']); $result = $findreq->execute(); if (FileMaker::isError($result)) { echo 'Error: (' . $result->getCode() . ') ' . $result->getMessage() . "n"; exit; } $records = $result->getRecords(); if (FileMaker::isError($records)) { echo 'Error: (' . $records->getCode() . ') ' . $records->getMessage() . "n"; exit; } Will get you what you need. Filemaker has a whole series of "find commands" There's a reasonable description of how they work in this pdf from Filemaker (starting on page 35)
November 21, 200817 yr Author sorry, the proverbial light bulb hasn't gone off yet. I follow (i think) your code. But how does $records (from your example) coincide with: $attendee = $fm->FUNCTION('layout', $_GET['Attendee_ID']); in other words, all of my attendee fields on the form are being pulled with: echo $attendee->getField('First Name'); so everything's based on $attendee, correct? How do i get $records involved? I feel like i'm close, but haven't connected this just yet. thank you OK so you need to know how to perform a find with the API. Will get you what you need. Filemaker has a whole series of "find commands" There's a reasonable description of how they work in this pdf from Filemaker (starting on page 35) $findreq = $fm->newFindCommand("layout_name"); $findreq->addFindCriterion("Attendee_ID", $_GET['Attendee_ID']); $result = $findreq->execute(); if (FileMaker::isError($result)) { echo 'Error: (' . $result->getCode() . ') ' . $result->getMessage() . "n"; exit; } $records = $result->getRecords(); if (FileMaker::isError($records)) { echo 'Error: (' . $records->getCode() . ') ' . $records->getMessage() . "n"; exit; }
November 21, 200817 yr Author got it! : so, after this: $records = $result->getRecords(); i needed to add THIS to isolate 'attendee' $attendee = $records[0]; works great now.. i can pass whatever field i like in the URL. Thanks for getting me 99% of the way : A rather large door just opened in my head. Excellent. many thanks!
November 22, 200817 yr I guess my post was a little obtuse. I'm glad you got it, but I'll attempt to clarify in the interest of anyone who might be come to this later. The successful execution of a find request $result = $findreq->execute(); Returns a Filemaker_Result object. The Filemaker_Result object has a function called getRecords() $records = $result->getRecords(); This returns an array of Filemaker_Record objects. It still returns an array even if it only finds one record. As bhamm pointed out you can access the first record in the array with $records[0] You can also loop through the array with foreach foreach($records as $rec){ $rec->getField("field_name"); }
Create an account or sign in to comment