[FX.php List] A little help with strings and arrays

Steve Bennett steve at bentechaps.com
Sat Mar 17 20:02:07 MDT 2007


I am trying to modify some code created by the FMStudio Site Builder  
to get a better understanding of FX-PHP and FileMaker. I have been  
able to create a set of checkboxes from a value list on my form but  
can not figure out how to get the checkbox fields from the form into  
FileMaker when creating a new record.


On the form the Category checkbox set is created using the following  
code:

       <?php
foreach(fmsValueListItems($managersitetest,'Expenses','CategoryType')  
as $list_item_key=>$list_item) {
   if( fmsCompareSet($list_item, "") ) {
     echo "<input name=\"category[{$list_item_key}]\" type=\"checkbox 
\" value=\"{$list_item}\" checked=\"checked\">{$list_item}<br>\n";
   } else {
     echo "<input name=\"category[{$list_item_key}]\" type=\"checkbox 
\" value=\"{$list_item}\">{$list_item}<br>\n";
   }
}
?>



The record creation page uses the following code to create a new  
record and fill in the fields from the form:

<?php require_once('../Connections/managersitetest.php'); ?><?php
$add_result_add = clone($managersitetest);
$add_result_add->layout = 'Expenses';
$add_result_fields = array('name'=>$_POST['name'],'category'=>$_POST 
['category'],'amount'=>$_POST['amount'],);
foreach($add_result_fields as $key=>$value) {
     $add_result_add->AddDBParam($key,$value);
}

$add_result_result = $add_result_add->FMNew();

if(is_a($add_result_result,"FX_Error") || $add_result_result 
['errorCode'] != "0") fmsTrapError($add_result_result,"error.php");

$add_result_row = current($add_result_result['data']);
$add_result_row_key = key($add_result_result['data']);
// FMStudioFX v1.0 - do not remove comment, needed for DreamWeaver  
support ?>



 From what I understand I have an array within an array and need to  
change the following section of code, from above, so that it creates  
a string from the array submitted by 'category'

$add_result_fields = array('name'=>$_POST['name'],'category'=>$_POST 
['category'],'amount'=>$_POST['amount'],);


I am not sure how to go about modifying the array within the array or  
if this is where it needs to be done?

Any guidance would be appreciated,

Steve


More information about the FX.php_List mailing list