Newbies SChaput Posted September 29, 2011 Newbies Posted September 29, 2011 Good day all, I am in the middle of trying to create this script so I can view our filemaker pro databases on the web. However, it seems to only be returning the last found record. I use $result = $cmd->execute(); $records = $result->getRecords(); which shows me the script finds 3 results, however all the content is outputted as if it were the last record. Find the entire code set below: <?php ini_set('error_reporting', 1); //config removed $return_field =array("ID", "Primary"); # set the layout name for this page $layout_name = 'Asset'; # this is the include for the API for PHP require_once ('Filemaker.php'); # instantiate a new FileMaker object $fm = new FileMaker(FM_FILE, FM_HOST, FM_USER, FM_PASS); $field = $_GET['field']; $search = $_GET['search']; $cmd = $fm->newFindCommand($layout_name); $cmd->addFindCriterion($field, $search); $result = $cmd->execute(); if( FileMaker::isError($result) ) { echo $result->getMessage() ; die(); } $records = $result->getRecords(); echo 'Total Records Found: ' . count($records); echo "<br><br>"; foreach($records as $record){ foreach($return_field as $field){ echo $field . ': ' . $record->getField($field) . '<br>'; } echo "<br>--------------<br>"; } Thanks for the help!
doughemi Posted September 29, 2011 Posted September 29, 2011 $return_field is undefined. Actually, you don't need or want that foreach(return_field) loop at all. foreach($records as $record){ echo $field . ': ' . $record->getField($field) . '<br>'; echo "<br>--------------<br>"; }
Newbies SChaput Posted September 29, 2011 Author Newbies Posted September 29, 2011 Thanks for the response, however, even removing that section of code still only returns the final result, but still sees that there are three total records found. <?php ini_set('error_reporting', 1); //config removed # set the layout name for this page $layout_name = 'asset'; # this is the include for the API for PHP require_once ('Filemaker.php'); # instantiate a new FileMaker object $fm = new FileMaker(FM_FILE, FM_HOST, FM_USER, FM_PASS); $field = $_GET['field']; $search = $_GET['search']; $cmd = $fm->newFindCommand($layout_name); $cmd->addFindCriterion($field, $search); $result = $cmd->execute(); if( FileMaker::isError($result) ) { echo $result->getMessage() ; die(); } $records = $result->getRecords(); echo 'Total Records Found: ' . count($records); echo "<br><br>"; foreach($records as $record){ echo $record->getField('ID') . '<br>'; echo "<br>--------------<br>"; }
Newbies prehn Posted June 26, 2013 Newbies Posted June 26, 2013 *BUMP* Did you solved this problem? Having the exact same issue with my php-site when i try to search thru the records in my database.
Newbies prehn Posted June 26, 2013 Newbies Posted June 26, 2013 Here it is! require_once ('FileMaker.php'); $fm = new FileMaker(); $fm->setProperty('database', 'xxxxx'); $fm->setProperty('hostspec', 'xxxxx'); $fm->setProperty('username', 'xxxxx'); $fm->setProperty('password', 'xxxxx'); $find =& $fm->newFindCommand('www'); $find->addFindCriterion('Namn', "ståhl"); $result = $find->execute(); $records = $result->getRecords(); //var_dump($records); echo '<table>'; foreach ($records as $record) { echo '<tr><td>'. $record->getField('Namn'). '</td><td>'. $record->getField('Befattning/Yrke'). '</td></tr>'; } echo '</table>';
doughemi Posted June 26, 2013 Posted June 26, 2013 I could duplicate your result (first record only returned) if I used FileMaker 11 PHP API files (FileMaker.php and the FileMaker folder). Switching to FileMaker 12 PHP API files corrected the problem. See http://help.filemaker.com/app/answers/detail/a_id/6531/~/manually-installing-the-filemaker-api-for-php
Recommended Posts
This topic is 4423 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