Dani Rubenstein Posted December 24, 2012 Posted December 24, 2012 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>
doughemi Posted December 24, 2012 Posted December 24, 2012 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>
Dani Rubenstein Posted December 25, 2012 Author Posted December 25, 2012 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>
doughemi Posted December 25, 2012 Posted December 25, 2012 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.
Dani Rubenstein Posted December 25, 2012 Author Posted December 25, 2012 Yes I have a layout with the portal in the Layout and it is pecifically for PHP interface
doughemi Posted December 26, 2012 Posted December 26, 2012 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.
Recommended Posts
This topic is 4607 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 accountSign in
Already have an account? Sign in here.
Sign In Now