Jump to content
Server Maintenance This Week. ×

Another easy question


This topic is 3867 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hello again!

 

I am attempting to create an array of results from a found set of Filemaker records within the FIlemaker PHP API.  I've managed to get the interactions working correctly but I'm having some difficulty in displaying the found fields and records.

 

I'm hoping that somebody more familiar with the way that PHP works can point me in the right direction.

 

Basically, I have performed a find command on an existing layout with two criterions:

  $findMedicalProvider =& $fm->newFindCommand('MedicalProviders');
            $findMedicalProvider->addFindCriterion('companyName', $providerName);
            $findMedicalProvider->addFindCriterion('companyType', 'Medical Provider');
            $result = $findMedicalProvider->execute();

This works as expect as I can see that the $result returns a boolean true and is not an error.

 

What I want to do is to take the records that are returned in this result and display them in an html table.  My PHP foo is pretty weak considering that I assume this is what A LOT of people want to do with their corresponding found set of records, but I'm having trouble with the PHP code required to do this.  I searched down and was reached the SFR introductory blog on PHP and it did help me get the results to display, but the format is not what I expected.  I think this is partly my fault, as I'm a visual learner and if I could actually SEE what is returned as the result of the find in $findMedicalProvider, it would go a long way in clarifying this.

 

Anyway, when I call a snipped of PHP thusly:


    <?PHP
    $records = $result->getRecords();
    foreach ($records as $record) {
      '<tr>';
      echo '<td>' . $record->getField('companyName') . '</td>';
      echo '<td>' . $record->getField('companyType') . '</td>';
      '</tr>';
    }
    ?>

A list of found records are returned but in a huge chunk of text.  Not being that familiar with PHP's syntax, I can't think of a way to format the code so that it will loop through the table header rows, table rows and table data rows accordingly.


Edit: Welp, just answered my own question.  I wasn't 'echo'ing' the first and last <tr> between each record.  Problem solved

Link to comment
Share on other sites

Hi James,

 

Please use below syntex which will help you to get the results in an arranged manner...

This is a piece of code from my project:

-----------------

<?php
include("connection.php");
$find = $fm->newFindCommand("Khan");
      
$find->addFindCriterion("Pid",$_POST["pid"]);
$find->addFindCriterion("Name",$_POST["nm"]);
$find->addFindCriterion("Address",$_POST["adr"]);
$find->addFindCriterion("City",$_POST["cty"]);
$find->addFindCriterion("State",$_POST["st"]);
$result = $find->execute();
$value = $result->getRecords();
?>

<table width="500" align="center" cellpadding="0" border="2" cellspacing="4">
<th align="center" bgcolor="#000000"><font color="#FFFFFF" size="+1">PID</font></th>
<th align="center" bgcolor="#000000"><font color="#FFFFFF" size="+1">NAME</font></th>
<th align="center" bgcolor="#000000"><font color="#FFFFFF" size="+1">ADDRESS</font></th>
<th align="center" bgcolor="#000000"><font color="#FFFFFF" size="+1">CITY</font></th>
<th align="center" bgcolor="#000000"><font color="#FFFFFF" size="+1">STATE</font></th>


<?php foreach($value as $recordvalue)
{?>
    <tr>    
        <td align="center"><?php echo $recordvalue->getField('Pid',0); ?></td>
        <td align="center"><?php echo $recordvalue->getField('Name',0); ?></td>
        <td align="center"><?php echo $recordvalue->getField('Address',0); ?></td>
        <td align="center"><?php echo $recordvalue->getField('City',0); ?></td>
        <td align="center"><?php echo $recordvalue->getField('State',0); ?></td>        
    </tr>
<?php } ?>
</table>

--------------

 

If you need more assistance please let me know.

Link to comment
Share on other sites

This topic is 3867 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.