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.

Featured Replies

Here is the code for using PHP/CDML to edit multiple records on one page.

This is the Format file which presents the data for editing. This example is using Checkboxes {yes,no} for each record:

<body>Hello World<br>

<form action="http://localhost/fmmultied.php" method="POST">

[FMP-Record]

[FMP-IF: yes_no .eq. Yes]

Yes<input type="checkbox" name="yes_no[]" value="[FMP-CurrentRecID]" checked>

[FMP-Else]

Yes<input type="checkbox" name="yes_no[]" value="[FMP-CurrentRecID]">

[/FMP-If]

<input type="hidden" name="rec_id[]" value="[FMP-CurrentRecID]"><br>

[/FMP-Record]

<input type="submit" value="Edit">

</form>

</body>





Here is the php script "fmmultied.php";


<?php



	$rec_ids = $_POST["rec_id"];

	$yes_nos = $_POST["yes_no"];

	

	for ($i = 0; $i < count ($rec_ids) ; $i++)

		{

		if (in_array ($rec_ids[$i],$yes_nos))

			{		

			$result = file_get_contents ("http://localhost:1154/FMPro?-db=combotest.fp5&-lay=multiedit&-format=ok.txt&-error=er.txt&-recid=" . $rec_ids[$i] . "&yes_no=Yes&-edit");

			}

		else

			{

			$result = file_get_contents ("http://localhost:1154/FMPro?-db=combotest.fp5&-lay=multiedit&-format=ok.txt&-error=er.txt&-recid=" . $rec_ids[$i] . "&yes_no=No&-edit");

			};

		} ;

		

	require ("index.html");

?>

The Format file "er.txt" and "ok.txt" have static content. They can be used to flag/log any errors that may occur.

Note that the function "file_get_contents()" is being used. Details of php functions etc can be found at:

http://www.php.net

Hope this is of interest.

Garry

  • 1 month later...

Do you (or anyone else) know of a way to do this using pure PHP and no CDML?

Thanks!

~Addam~

  • Author

I guess using the FX Class you are using XML requests rather than CDML. I saw a thread where somebody showed how to do multiple edits with the FX Class. Alternatively you can process the XML yourself without the FX Class.

The initial Form is still the same where you use an array. For example:

....

<input type="hidden" name="recid[]" value="[FMP-CurrrentRecID]"><input type="text" name="firstname[]" value="">

.....

The php script could look something like this:

<?php 



$rec_ids = $_POST["rec_id"]; 

$fnames = $_POST["firstname"]; 



for ($i = 0; $i < count ($rec_ids) ; $i++) 

{ 

$result = file_get_contents ("http://localhost:1154/FMPro?-db=combotest.fp5&-format=-fmp_xml&-recid=" . $rec_ids[$i] . "&firstname=" . $fnames[$i] . "&-edit"); 

} ; 



require ("index.html"); 

?> 

Hope this helps.

Garry

GARRY!!!

You are the MAN!!!

After all of that cussing and shouting... My Co. Worker comes over to me and say's "ohh... you need to change your "status" to "status[]".

And it worked! I didn't even thing about the "[]".

I'm trying not to kick myself too hard.

Thank you so much for your help!!

Cheers!

Hi Garry!

I was able to understand and get the edit functions to work. My problem was I kept getting warning and notices on the screen and treating them as ERRORS thinking it wasn't working. My brain was fried. I'm good now though.

I do have one question though. I may have come up with a method of "Finding Multiple Records" however, I'm not sure if it would be the way to go, but it's what I came up with.

Basically the user group would get a list. The then would select all they wanted to edit and click on a link that say's "Edit Selected".

I've worked this out with JavaScript & CDML before, by using a form field to keep track of the array (it's easier) then, set a form value equal to all of the requests and CDML would find them.

I'm kind of puzzled on this moving using PHP. Using FX, I can find one record with ease, even multiple ones, but it's all preset. Do you or anyone out there know of a way to do this type of backend transaction with ease?

Thanks a million!

  • Author

This can be done with PHP. I think the easiest way maybe to have an edit field in the Form. Your PHP script can check that field and only edit those records. For example (very brief):

HTML Form:

<input type="checkbox" name="editOK[]" value="yes">

PHP Script:

$editOK = $_POST["editOK"];

if ($editOK[$i] == "yes")

{

$editresult = file_get_contents("http://localhost:591/FMPro?-db.......&-edit");

};

Hope this leads you the direction of a solution.

Good Luck.

Garry

HI Garry...

Thanks again for your input. I'm still kind of struggling with this, but I'm sure I'm headed the right direction. There is one thing I'm going to point out that all should know...

When using the code you posted for editing multiple records...

If you are going to be using a field that contains more than 1 value "word"...

Example: $addam = "Addam Driver"; and not $addam="AddamDriver"

wrap your "$tag" in the "rawqurlencode()" tag... This will parse it and properly send the information back to FMP.

Example: if $addam = "Addam Driver"...

You would right this as: rawurlencode($addam) in your http: request line.

This was causing me so many problems until I opened my PHP book and ran across it.

Hope this helps someone...

~Addam~

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.