October 13, 201015 yr 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(); }
October 14, 201015 yr 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"; }
October 14, 201015 yr 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 October 14, 201015 yr by Guest
October 14, 201015 yr 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