December 24, 201213 yr Hi to all. i have a php page that gives me all company names. I what to have all of the branches in a table in the bottom of the page. this is the php code. thanks dani <html> <?php // Include FileMaker API require_once ('FileMaker.php'); include ("conect.php"); $record = $fm->getRecordById('web Main', $_GET['recid']); if (FileMaker::isError($record)) { echo "<body>Error: " . $record->getMessage(). "</body>"; exit; } ?> <head> <title><?php echo $record->getField('Company Name'); ?></title> <!-- declare charset as UTF-8 --> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" href="style.css"> </head> <body dir="rtl"> <table> <tr> <th id="table-title" colspan="3">a</th></tr> <tr> <th>b</th><td><?php echo $record->getField('Company Name'); ?></td></tr> <tr> <th>c </th><td><?php echo $record->getField('company phone'); ?></td></tr> <tr> <th>d</th><td><?php echo $record->getField('company fax'); ?></td></tr> <tr> <th>e</th><td><?php echo $record->getField('company Mobile'); ?></td></tr> <tr> <th>f</th><td><?php echo $record->getField('company email'); ?></td></tr> <tr> <th>g</th><td><?php echo $record->getField('Status'); ?></td></tr> <tr> <th>h</th><td><?php echo $record->getField('note'); ?></td></tr> <tr><td colspan="2" style="text-align: center"><a href="editRecord.php?recid=<?php echo $record->getRecordId(); ?>">edit</a></td></tr> <tr><td colspan="2" style="text-align: center"><a href="deleteRecord.php?recid=<?php echo $record->getRecordId(); ?>">Delete this record</a></td></tr> <tr><td colspan="2" style="text-align: center"><a href="displayRecords.php">Back to Record List</a></td></tr> </table> <?php $relatedSet = $record->getRelatedSet('cliant company'); //check for an error if (FileMaker::isError($relatedSet)) { echo "<p>Error: " . $relatedSet->getMessage(). "</p>"; exit; } echo $relatedSet; ?> </body> </html>
December 24, 201213 yr Try <?php $relatedSet = $record->getRelatedSet('cliant company'); //check for an error if (FileMaker::isError($relatedSet)) { echo "<p>Error: " . $relatedSet->getMessage(). "</p>"; exit; } echo $relatedSet; echo "<table>n" $records = $relatedSet->getRecords(); foreach($records as $record){ echo "<tr><td>" . $record->getField('branchname') . '</td><td>' . $record->getField('branchaddr') . '</td></tr>'; // include whatever other fields desired in row } echo "</table>n"; ?> </body> </html>
December 25, 201213 yr Author for i reason it is not working. <html> <?php // Include FileMaker API require_once ('FileMaker.php'); include ("conect.php"); $record = $fm->getRecordById('web Main', $_GET['recid']); if (FileMaker::isError($record)) { echo "<body>Error: " . $record->getMessage(). "</body>"; exit; } ?> <head> <title><?php echo $record->getField('Company Name'); ?></title> <!-- declare charset as UTF-8 --> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" href="style.css"> </head> <body dir="rtl"> <table> <tr> <th id="table-title" colspan="3">a</th></tr> <tr> <th>b</th><td><?php echo $record->getField('Company Name'); ?></td></tr> <tr> <th>c </th><td><?php echo $record->getField('company phone'); ?></td></tr> <tr> <th>d</th><td><?php echo $record->getField('company fax'); ?></td></tr> <tr> <th>e</th><td><?php echo $record->getField('company Mobile'); ?></td></tr> <tr> <th>f</th><td><?php echo $record->getField('company email'); ?></td></tr> <tr> <th>g</th><td><?php echo $record->getField('Status'); ?></td></tr> <tr> <th>h</th><td><?php echo $record->getField('note'); ?></td></tr> <tr><td colspan="2" style="text-align: center"><a href="editRecord.php?recid=<?php echo $record->getRecordId(); ?>">עריכה</a></td></tr> <tr><td colspan="2" style="text-align: center"><a href="deleteRecord.php?recid=<?php echo $record->getRecordId(); ?>">Delete this record</a></td></tr> <tr><td colspan="2" style="text-align: center"><a href="displayRecords.php">Back to Record List</a></td></tr> </table>kk <table border="1"> <tr><td>fff</td></tr> <?php //check for an error //if (FileMaker::isError($relatedSet)) { // echo "<p>Error: " . $relatedSet->getMessage(). "</p>"; // exit; //} ?> <?php $relatedSet = $record->getRelatedSet('cliant company');// cliant company is a related table $records = $relatedSet->getRecords(); foreach($records as $record){ echo "<tr><td>" . $record->getField('company name') . '</td><td>' . $record->getField('company name') . '</td></tr>'; // include whatever other fields desired in row }?> </table> ?> </body> </html>
December 25, 201213 yr Remember that the PHP API is layout-centric. Do you have a portal to the related table on your layout? It's a good idea to create layouts specifically for PHP interface, each with just the fields required by the PHP script.
December 25, 201213 yr Author Yes I have a layout with the portal in the Layout and it is pecifically for PHP interface
December 26, 201213 yr I just tried to do a sample and couldn't get it to work either. Someone told me long ago that getRelatedSets() was difficult to work with. What I DID get to work is the way I usually do it: Use a newFindCommand( {layout native to the related table}) with addFindCriterion the same as your relationship criteria, and pull your records from that found set.
Create an account or sign in to comment