Jump to content
Server Maintenance This Week. ×

Can someone please tell me a way of creating...


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

Recommended Posts

I need a solution, workaround, anything to get this to work. I need to add mutliple records to a database based on the amount of records in another database. Then I need to edit those records. I have looked into everything there is. Php I thought would work but it says in the FX.php class that you can have only one query string on a page so that would eliminate that. I have tried portals and the .0 without success. Is there any way of doing this?

Justin Grewe

Link to comment
Share on other sites

How come this will not work Garry?

<form action="FMPro" >

<input type="hidden" name="-db" value="Evalrespond1.fp5" />

<input type="hidden" name="-lay" value="AdminRespond" />

<input type="hidden" name="-format" value="-fmp_xml" />

<input type="hidden" name="-styletype" value="text/xsl"/>

<input type="hidden" name="-stylehref" value="findquestions.xsl"/>

[FMP-Record]

<input type="hidden" name="Evalrespond1::QuestionID.0" value="[FMP-Field: QuestionID]"/>

<input type="hidden" name="Evalrespond1::RegistrationID.0" value="[FMP-CurrentToken:0]" />

[FMP-Record]

<input type="hidden" name="-recid" value="44702"/>

<input type="submit" name="-edit" value="Submit" />

</form>

Where for every record in one database it creates a new portal row in the other. Otherwise can you be more specific on how to do this with portals?

Thanks,

Justin Grewe

Link to comment
Share on other sites

"Evalrespond1::RegistrationID.0" creates a new related record (one only). To edit existing Portal Rows you could use this:

<input type="hidden" name="Evalrespond1::QuestionID.[FMP-CurrentRecordNumber]" value="[FMP-Field: QuestionID]"/>

<input type="hidden" name="Evalrespond1::RegistrationID.[FMP-CurrentRecordNumber]" value="[FMP-CurrentToken:0]" />

This line:

<input type="hidden" name="-db" value="Evalrespond1.fp5" />

would need to reference the Master DB, not the Related DB.

I would need to look at the whole application to advise accurately on the best solution.

All the best.

Garry

Link to comment
Share on other sites

Actually, with FX you can make as many DB calls in a single PHP script as you like. Here is a particularly useful example, which allows you to create X number of entries in the database to match X number of provided input from an HTML form:


<body>

<?

if ($_REQUEST['mySubmit']) {

	[color:"green"]// User clicked the mySubmit button[/color]

	

	require("../fx/FX.php");

	foreach ($_REQUEST["userName"] as $userName) {

		[color:"green"]// Create a new record for each userName[] input

		// that is not empty

		//[/color]

		$q = new FX ("127.0.0.1", "591");

		$q -> SetDBData ("userName.fp5", "web");

		$q -> AddDBParam ("name", $userName);

		$q -> FMNew();

		

		print ("Record inserted: ".$userName."<br>n");

	}

}

?>

<form name="myForm" action="<?=$PHP_SELF?>" method="post">

	<input type="text" name="userName[]" value=""><br>

	<input type="text" name="userName[]" value=""><br>

	<input type="text" name="userName[]" value=""><br>

	<input type="text" name="userName[]" value=""><br>

	<input type="submit" name="mySubmit">

</form>

</body>

Perhaps you misunderstood what you read? You can only submit one URL to a PHP script, but that one PHP script can in turn send unlimited URLs to another program (such as FileMaker).

Further, PHP makes it very easy to read in a list of submitted Form Inputs, work with them as an array, and if you want take an action for each Form Input. This is one of the many strengths of PHP. =)

Link to comment
Share on other sites

Please read my previous post first...

It is also easy to find records in one table and create child records for them in another table. Here is an example that finds all the records in the "parent.fp5" table and create one related child for each parent:

<?

require("../fx/FX.php");

 

[color:"green"]// Find all records in parent table[/color]

$q_parent = new FX("127.0.0.1", "591");

$q_parent -> SetDBData("parent.fp5", "web");

$r_parent -> FMFindAll();

 

[color:"green"]// For each parent, create one related child[/color]

foreach ($_parent['data'] as $parent_row) {

	$q_child = new FX("127.0.0.1", "591");

	$q_child -> SetDBData("child.fp5", "web");

	$q_child -> AddDBParam("key_parentID", $parent_row['key_primary'][0];

	$q_child -> FMNew();

	print ("Child created for parent ".$parent_row['key_primary'][0].".<br>n";

}

?>



Link to comment
Share on other sites

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