Discussion created by mjohnson24 on Dec 7, 2018
Latest reply on Dec 10, 2018 by mjohnson24

Hey Everyone! I have an issue. I know how to use PHP API for filemaker and pull records and add records etc. In the screenshot is a list of records. Each one is unique. I pull that from the services table by the newFindCommand. In the screenshot for this instance is 5 records, each record has an input field where the client will go and enter a numeric value like 100 or 250 etc. It also has a hidden input field that has a name of "id" and a value of the service record id thats unique for each of the records in the list. The code below is what displays my records in the browser. That part works like a charm with no issues for me.


The issue i have is when i click the submit button, the $_POST array only gives me two pieces of data (Hidden id field and the inout levelAmount field value) for the last record in that list but i need all 5 but in a way that it has the hidden ID field and level amount thats unique for each record so i can loop through and send it back to filemaker in a different table. Right now i do show the ServiceID in the list of records in the browser but its also in the hidden inout field. The display one wont be showing visually in the browser when im done. But thats a moot point really. I only show it so i can compare what i have and what i get from FM making sure it gives me the correct records in my initial find.


Once i get the records to display that part is done. All i need to do is somehow get the records in the $_POST array correctly so i can loop through that. The array i have posted below shows what i get and what im trying to get.



Do yall follow me so far?




<form action="" method="POST">



        echo '<table>




                    <th>Unit Serial #</th>

                    <th>Service ID</th>





        #LOOP THROUGH $records variable from variable to list all records it got from my first and original table.

        foreach ($records as $record) {

            echo '<tr>';

            echo '<td>' . $record->getField('Location') . '</td>'; #ONLY FOR DISPLAY PURPOSES

            echo '<td>' . $record->getField('SerialNumber') . '</td>'; #ONLY FOR DISPLAY PURPOSES

            echo '<td>' . $record->getField(' RECID') . '</td>'; #ONLY FOR DISPLAY PURPOSES

            echo '<td><input type="text" name="LevelAmount"></td>'; #I NEED THIS IN $_POST array

            echo '<td><input type="hidden" name="id" value="' . $record->getField('RECID') . '"></td>'; #I NEED THIS IN $_POST array

            echo '</tr>';


    echo '<tr><td><input type="submit" value="Submit"></td></tr>';

    echo '</tbody></table>';







#Array im getting currently that is only getting the last record




        [LevelAmount] => 151

        [id] => S1151






#Array format im trying to accomplish. This will allow me to loop through each position of the multi demensional array and get both pieces of data for each record i need created in new table in filemaker.


with this i can something like this to add to filemaker


$addRecord = $fm->newAddCommand('php layout name here');


foreach($_POST as $id=>$amount) {

     $addRecord->setField("ServiceID", $_POST['id']);

     $addRecord->setField("Amount", $_POST['LevelAmount']);


  $added = $addRecord->execute();





     #RECORD 1


        [LevelAmount] => 147,

        [id] => S1147



     #RECORD 2


        [LevelAmount] => 148,

        [id] => S1148



     #RECORD 3


        [LevelAmount] => 149,

        [id] => S1149



     #RECORD 4


        [LevelAmount] => 150,

        [id] => S1150



     #RECORD 5


        [LevelAmount] => 151,

        [id] => S1151






Do yall follow me what im trying to do or accomplish?