Jump to content

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

Recommended Posts

  • Newbies
Posted

Im creating a new entry using FMNew() and I have a ID# that is generated for every new entry (in my FM DB) but I can't seem to be extract the info.

<?php

include_once('FX/FX.php');

include_once('FX/server_data.php');

include_once('FX/FMErrors.php');

$user=$_POST ["user"];

$newrecord=new FX($serverIP,$webCompanionPort);

$newrecord->SetDBData("demandereparation.fp5","Web");

$newrecord->AddDBParam("user",$user);

$newResult=$newrecord->FMNew();

?>

I try to extract the FM variable ID but I always get an error.

I tried adding this to my code to get it to show.

foreach($newResult["data"] as $key=>$newData)

{}

echo $newData ["ID"][0];

I also tried to print_r($newData) but it's empty but the new record was successfully created in my FM DB.

Any help would be greatfully appreciated.

Thanks

  • Newbies
Posted

Finally found an answer. Didn't know I could simply add another instance that did a FMFind(). Everything works great.

New code if this can help others

<?php

include_once('FX/FX.php');

include_once('FX/server_data.php');

include_once('FX/FMErrors.php');

$user=$_POST ["user"];

$newrecord=new FX($serverIP,$webCompanionPort);

$newrecord->SetDBData("demandereparation.fp5","Web");

$newrecord->AddDBParam("user",$user);

$newResult=$newrecord->FMNew();

foreach($newResult["data"] as $key=>$newData)

{}

$recordDetails=explode(".",$key);

$currentRecord=$recordDetails[0];

$recid=$currentRecord;

$findrecord=new FX($serverIP,$webCompanionPort);

$findrecord->SetDBData("demandereparation.fp5","Web");

$findrecord->AddDBParam("-recid",$recid);

$findResult=$findrecord->FMFind();

foreach($findResult["data"] as $key=>$findData)

{}

echo $findData["ID"][0];

?>

Posted

Hi siroisv,

I am working on a survey page with 150 quesions, I am having some problem to keep adding information to a related record where I have I have several webpage instead one. Do you have any idea how should I have it working?

thank you,

msei :confused:

Posted

Hello,

You're method works, but you're wasting precious resources by making hitting the DB twice. Here's a less verbose method with just a single hit and you can grab the recid or any other field you want:


$Add = new FX($serverIP,$webCompanionPort);

$Add->setDBData('users.fp7','layout');

$Add->AddDBParam('firstname','$FirstName');

$Add->AddDBParam('lastname','$LastName');

$AddResult=$Add->FMNew();



// Assuming you trapped for all errors and successfully added the new record...

foreach($AddResult['data'] as $AddKey=>$AddRecord)

$FMRecordID = explode('.',$AddKey);

$CurrentAddRecord = $FMRecordID[0];

$UserID = $AddRecord['UserID'][0]



echo "Record ID: ".$CurrentAddRecord";        // Grab the recid

echo "User ID: ".$UserID";                              // Grab data from 'UserID' field

In this example, I add a new record to users.fp7. My table has a serial number field, users:UserID, that is autopopulated with a serial number in FileMaker. Sometimes, I need the recid, other times I need the serial number.

Hope this helps,

Shannon

-=-=-

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