list the bookings using FileMaker PHP Api which has a bigger id than 152810

88 Views Asked by At

I am trying to list the latest bookings on my filemaker pro database. There are hundreds of bookings in the database. I just want to list the ones which has a bigger ID than 152810.

So, my table looks like in the screenshot below (The screenshot you see is made in excel not my output. I am trying to get the exact look as it is on the screenshot.)

enter image description here

include("filemaker.php"); 
$id = "152801"; 
$fm = new FileMaker('OpenBooking', 'myhost', 'admin','passw0rd'); 
$findCommand = $fm->newFindCommand("Bookings"); 
$findCommand->addFindCriterion("_kpnID",'>'.$id); 
$result = $findCommand->execute(); 
if (FileMaker::isError($result)) { 
    echo ($result->getMessage()); 
    return; 
} 
$records = $result->getRecords();
foreach ($records as $record => $id)  
$records->getField("_kfdTourDate");

I am getting this error:

Fatal error: Call to a member function getField() on a non-object in D:\XAMPP\htdocs...

If I use

$records = $result->getFirstRecord(); 

instead of

$records = $result->getRecords(); 

it lists the first row accurate.

First time I am using filemaker php api. I would appreciate any suggestion about how to display the rows as in the screenshot above.

1

There are 1 best solutions below

9
On

First make sure that your "sales" layout is exists and then do a small change as flowing.

include("filemaker.php");
$id = "152810";
$fm = new FileMaker('mySales', 'myhost', 'admin','passw0rd');
$findCommand = $fm->newFindCommand("sales");
$findCommand->addFindCriterion("_kpnID",'>'.$id);
$result = $findCommand->execute();
if (FileMaker::isError($result)) {
    echo($result->getMessage());
    return;
}
$records = $result->getRecords(); 
foreach ($records as $record => $id)