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

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

Recommended Posts

Posted

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();

			

		}

Posted

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

}

Posted (edited)

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
Posted

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.

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