Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

Couple of probs: empty results (first time only) + linking


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

Recommended Posts

Posted

I'm just getting my head into CWP with the Filemaker PHP API (should have done it ages ago!!), with the goal of being able to access our Contacts and Events data online, but I've hit a couple of problems.

PHP is new to me, although I've learned a whole bunch by dissecting the Site Assistant generated code.... but I've hit a few issues which have me stuck!

Problem 1: The first time I use the 'findrecords.php' page and enter my criteria, I move to the 'recordlist.php' page fine, but there's nothing in it.... refresh the page, and the data is there. Any thoughts?

Problem 2: I duplicated the recordlist.php file (record_detail.php) so I can have both "lean" and "mean" versions of the same data. I want the user to be able to scroll through the lean list of company names, and when they click on one, are taken to the mean detailed version. I thought I had the eureka moment by parsing the recordID into the '-skip' element of the link string, but this only works for the first page of results (i.e. if I'm browsing records 26-50 and click the 4th in the list, I'm taken to the detail of record 4, not 30. Make sense??).

Then I read some stuff, and tried generating a link for each of the records – ../recorddetail.php?recordID=30 – but this doesn't work either... I'm obviously missing something, and some help really would be appreciated.

Once I get the contacts sorted, the events are very similar – I need to show data from a portal of forthcoming live events, and allow users to click the event in the list to view the detail.

Posted

Trying to learn PHP by looking at Site Assistant's code is like trying to learn English by listening to G W Bush.

Scrap the site assistant; look at the PHP API example included with FMS; and use that as a template to build the pages you need. It will likely be faster than chasing down all problems you'll run into as you tweak the SA code.

Posted

haha.. yes, indeed!

Seriously though, it's all coming together nicely – I just need to figure out what I need to do in the 'details.php' file to find the single record I'm trying to pass via a variable in the URL (i.e. details.php?eventRecordID=10236).

I'm guessing it's to do with $_GET['eventRecordID'] somehow and passing it to a find request??

Once I get this, I'm pretty much there....

Posted

assuming eventRecordID is Filemaker's internal record id for the event table (as opposed to a field in the table which is set up as the Primary Key), you can use


$record = $fm->getRecordById('event_layout', $_GET['eventRecordID']);

/*error checking is always helpful*/

if($fm->isError($record)){

	echo "ERROR( " . $record->getCode() . ") " . $record->getMessage();

	exit();

}





to get the record



otherwise you'll have to run the search





$req = $fm->newFindCommand("event_layout");

$req->addFindCriterion("eventRecordID",$_GET['eventRecordID']);

$result = $req->execute();

if($fm->isError($req)){

	echo "ERROR( " . $req->getCode() . ") " . $req->getMessage();

	exit();

}

$records = $req->getRecords();



/*assuming search is on Primary Key 

i.e. will alway return a single record.

Just grab the first and only value in the array*/

$rec = $records[0];

Posted

Thanks Baloo – that's very useful. I will give this a bash when I get into the office tomorrow, but I tried something very similar earlier today, and it didn't work... I think it's something to do with the code at the very beginning of the eventDetails.php page – seems to me like find requests are reset?

Am I giving myself problems by trying to do this $GET_ find request across layouts?

Further details just in case.....

My main Filemaker solution has an Interface file, which connects to a Data file. I use multiple portals and relationships within the Interface file to show Events in a timeline (different ranges) and also within each Contact record etc..etc...

Before I embarked on CWP, I created new layouts within Interface – iPortal, iEvents and iContacts (perhaps not very imaginitive, but there you go!!). These are stripped bare of all unnecessary fields, and when browsed via Filemaker, all work as expected.

I used Site Assistant to create a simple "find and list" PHP site for each of these layouts, and proceeded to 'tweak' the auto-generated code, and am almost there.

My home.php page has two links to navigate to either ../events/events_browser.php or ../contacts/contacts_list.php

I can click a record in the events_browser.php and link to the correct record in eventDetails.php (using a concocted hidden field form submission, based on the findrecords.php file... nasty, but it works)

I can also go from the contacts_list.php to contactDetails.php using a similar method.

However, if I go back to home.php and subsequently try to view the events_browser.php file, I get an error: 102 – field missing. What gives??

Also, I get the same error if I try to go to one of the events related to a client from the portal on my contactDetails.php file.

I'm so close to getting this up and running, and feel like I'm missing something simple.. please help!!

  • 3 months later...
Posted

I found the Site Assistant files extremely useful as a crash course in v.10 web publishing. Granted, I had already read a good book on PHP and had some previous programming experience with various languages such as Javascript, C++, and PHP itself (without accessing any databases).

But I agree, the FileMaker Server 10 "Custom Web Publishing with PHP" pdf document is truly the mother lode when it comes to understanding the FileMaker API for PHP.

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