Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

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

Recommended Posts

  • Newbies
Posted

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!

Posted

$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
Posted

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>";

}

  • 3 weeks later...
  • 1 year later...
  • Newbies
Posted

*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
Posted

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>';

This topic is 4158 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.