[FX.php List] Conditional value lists with PHP and FileMaker
Andrew Denman
adenman at tmea.org
Wed Nov 19 14:06:16 MST 2008
You can use a groupsize of 'all' that will return all records instead of specifying a set number (especially if you don't know how big the list will get). That I know of you can't get the unique set in the initial query so they way you're doing it is the way to go. Take a look at array_unique() function to reduce your district list down after getting it into the array:
http://us.php.net/manual/en/function.array-unique.php
Andrew Denman
-----Original Message-----
From: fx.php_list-bounces at mail.iviking.org [mailto:fx.php_list-bounces at mail.iviking.org] On Behalf Of Anders Monsen
Sent: Wednesday, November 19, 2008 10:46 AM
To: FX.php Discussion List
Subject: [FX.php List] Conditional value lists with PHP and FileMaker
Has anyone on the list worked on this issue? I spent most of yesterday
putting together a process that works, but may not be the most
efficient process. I was wondering if anyone would be open to looking
at my code (the snippet is 130 lines long at minimum, so I didn't just
want to throw it out there) to see if there are ways I can improve the
process. It certainly made me appreciate how easy FileMaker makes this
process...
(I just discovered and read Jonathan Stark's article in July
FileMakerAdvisor after writing this email. It uses Ajax, so I may try
to incorporate his techniques, although I'm using FX.php and no
existing value lists from FileMaker, just existing data.)
Here's the scenario. I have a table with four fields: district number,
district name, campus number, and campus name. I want the district and
campus to be drop down menus, where the user sees the name but submits
the number into another FileMaker database/table. Also, when the user
selects a district, I need the value list of campuses to correspond
just to their appropriate district.
My first issue was to find a way to create an associative array with
district numbers=>district names. Apparently I took the hard route in
dynamically building associative arrays... After several failed
attempts, I used a function that I found on php.net in the section on
"array_push" to create this array. The first problem I ran into was
that the list currently contains 270 records. For now I had to
manually change the groupsize in the query to above 300, but I plan to
first query all records to get a count, then make this the groupsize.
The reason for this is that the district array becomes unique only
after all records have been loaded into the array, so the default
groupsize of 50 has to be modified.
Is there a way to 1) build a better array and 2) make the district
array unique in the initial query? The database is structured as one
file, with all four fields, and so the district numbers and names are
repeated. I didn't create the database, and I can't change it.
Distnum | Distname | CampusNum | Campus Name
10 The ISD 2 School
10 The ISD 2.1 OtherSchool
etc.
Additionally, after several failed attempts to get the Javascript
onchange function to work when the form changed, I resorted to
DreamWeaver's JumpMenu, which seems to work fine. Has anyone been able
to get a working onchange form and what is the correct syntax? When
the user selects a district from the dropdown, the page reloads with
the district number in the URL.
Given all of the above, my process *does* work, and the page does not
appear to load with delays. I have not used conditional values lists
with PHP/Javascript in about three years, so I am a little unsure of
best practices.
Thanks,
Anders
_______________________________________________
FX.php_List mailing list
FX.php_List at mail.iviking.org
http://www.iviking.org/mailman/listinfo/fx.php_list
More information about the FX.php_List
mailing list