troubleshooting Question

Update FileMaker Database API PHP Code to Retrieve Query String

Avatar of smower
smower asked on
PHPFileMaker Pro
8 Comments2 Solutions1612 ViewsLast Modified:

I have a little php site created by a wizard software that pulls data out of FileMaker.  I have a current page that currently retrieves the record id out of the url to look up the database record and display the fields from the record.  I want to make a slight modification that will allow me to instead send a PO parameter that would instead look up the record by the PO number instead of the record id when PO=12345 is sent in the query string.  I still want the existing functionality but need to know how to make it either look up record id or po number.  Here is the existing php section that pulls out the record id.


    * FileMaker PHP Site Assistant Generated File

    require_once 'fmview.php';
    require_once 'FileMaker.php';
    require_once 'error.php';

    $cgi = new CGI();
    $databaseName = 'SalesFM7';
    $layoutName = 'XSLEditLayout';

    $userName = $cgi->get('userName');
    $passWord = $cgi->get('passWord');

    $fm = & new FileMaker();
    $fm->setProperty('database', $databaseName);
    $fm->setProperty('username', $userName);
    $fm->setProperty('password', $passWord);
    $layout = $fm->getLayout($layoutName);

    // formats for dates and times
    $displayDateFormat = '%m/%d/%Y';
    $displayTimeFormat = '%I:%M:%S %P';
    $displayDateTimeFormat = '%m/%d/%Y %I:%M:%S %P';
    $submitDateOrder = 'mdy';

    $recid = $cgi->get('-recid');
    if (!isset($recid))
        $recid = 1;
    $record = $fm->getRecordById($layoutName, $recid);
    class EmptyRecord {
        function getRelatedSet($relationName) {
            return array(new EmptyRecord());

        function getField($field, $repetition = 0) {

        function getRecordId() {
In slight testing on a test page it seems like the following type of code is needed to pull a po number:

$cmd =& $fm->newFindCommand('XSLLayout');
$cmd->addFindCriterion('PO', $_REQUEST['PO']);
$result = $cmd->execute();
if (FileMaker::isError($result)) {
    echo 'unable to find PO: ' . $result->message . '(' . $result->code . ')';
$records = $result->getRecords();
Does anyone know how to tweak these two pieces of code to work together to make my page a little more dynamic in allowing me either url search?



as is working currently only:


Thanks in advance,

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 8 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros