[FX.php List] Conditional value lists with PHP and FileMaker

Anders Monsen andersm at alamark.com
Wed Nov 19 10:06:04 MST 2008


Hi Steve,

Apparently pastebin is a site where you can upload some code, and the  
color code this for other users to see the appropriate language coding.

Yes, the database is not user-friendly, and not relational, and I'm  
stuck with it as it's part of a large solution and would involve major  
re-structuring of the rest of the FileMaker databases, but that is  
another story. In this instance I have control over the PHP and web  
design only.

I have done this with MySQL in the past, but with a slightly different  
table structure. If the link below doesn't work I can email you the  
file, and welcome any comments. I will look into Ajax next, as Stark's  
article contained some interesting enhancements.

http://pastebin.com/m11a42e0c

Thanks,
Anders

On Nov 19, 2008, at 10:58 AM, Steve Winter wrote:

> Hi Anders...
>
> Doesn't sound like a very user-friendly database structure that  
> you're stuck with...!! clearly the concept of 'relational' was lost  
> on the original builder...
>
> I've done a similar type of thing... originally I used JavaScript  
> and built large JavaScript arrays to hold all of the data...  
> everything but the first dropdown 'locked', when a selection was  
> made from that I populated the second drop-down (using JavaScript)  
> and made it active, and so on across the table...
>
> My second version used Ajax to do basically the same thing, however  
> in both instances I was working from relational data which certainly  
> makes things easier...
>
> I'd be more than happy to take a look at your code and see if I can  
> make any suggestions for improvement if you're interested... feel  
> free to send it to me off-list... (I have no idea what ggt was  
> saying ;-)
>
> Cheers
> Steve
>
>
> On 19 Nov 2008, at 16:46, Anders Monsen wrote:
>
>> 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
>
>
> _______________________________________________
> 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