grumbachr Posted October 13, 2010 Posted October 13, 2010 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(); }
Genx Posted October 14, 2010 Posted October 14, 2010 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"; }
Genx Posted October 14, 2010 Posted October 14, 2010 (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 October 14, 2010 by Guest
grumbachr Posted October 14, 2010 Author Posted October 14, 2010 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.
Recommended Posts
This topic is 5410 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