Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Finding Records in FM from Array

Featured Replies

I have an Array it contains the value from a key field in my database. The key is for sessions of a class. The keys display fine but I now need to take this and show other related data from FM.

I have been reading and searching for many hours trying different things but have not had any luck. If someone could point me in the right direction I'd be very grateful.

Here is my PHP code to display the Keys after they are selected from another page/form.

if (isset ($_POST['cart']) and 



	is_array($_POST['cart']))	{

	

		foreach ($_POST['cart'] as $id) {

		

			$html .= "$id

n";

			

		}






Can I do something like 




if (isset ($_POST['cart']) and 



	is_array($_POST['cart']))	{

	

		 foreach ($_POST ['cart'] as $id) {

       $record = $fm->newFindCommand ('php_Session');

       $request -> addFindCriterion ('Field', $id) ;

       $result = $request->execute();

			

		}

Presuming you send the user to a seperate page (e.g. session_detail.php) and append the id to the url (e.g. session_detail.php?id=3), you can do something like this:


if( $_REQUEST['id'] ){

$find = $fm->newFindCommand ('php_Session');

$find -> addFindCriterion ('Field', $_REQUEST['id']) ;

$result = $find->execute();

if( FileMaker::isError($result ) ){

die('You did not specify a valid session id');

} else {

$record = current($result->getRecords());

}

} else {

echo "you must specify a session id";

}

On rereading your post you want to get more info about the cart items in the user's cart??

You can do what you've used in your example, only the lines:

$record = $fm->newFindCommand ('php_Session');

$request -> addFindCriterion ('Field', $id) ;

$result = $request->execute();

should be:


$request = $fm->newFindCommand ('php_Session');

$request -> addFindCriterion ('Field', $id) ;

$result = $request->execute();

/*error trapping here*/

$record = current($result->getRecords());

Not exactly the most efficient way to do it (you should actually create a compound find command), but it will work.

Edited by Guest

  • Author

Thank you very much.

I had one other error that was giving me trouble but what you provided worked like a dream.

Next step. Creating the records from that list.

Again thanks a million.

Create an account or sign in to comment

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.