[FX.php List] Suggestions on editing a list of check boxes

Tim 'Webko' Booth tim at nicheit.com.au
Mon Sep 1 17:11:12 MDT 2008


On 02/09/2008, at 1:52 AM, John Funk wrote:

> I have HTML form that list the results of an FM query in a check box  
> format.
> I would like to then send that list (all (records with user changes)  
> back to
> the same FM layout (table) with FMEdit().
> Can anybody give an example for capturing, sending and getting  
> arrays of
> data between php files, then parsing to edit the records? I  
> understand the
> FMEdit() part.

A simpl;ified version of one of my forms - note that this one is  
actually a FMNew, but the principle for capturing checkboxes and  
deciding which code to perform is much the same. There is no error  
checking on this one, although there are some variables to use for  
that if you wish. And given that I've pretty much taught myself, there  
is almost certainly room for improvement i nthe elegance of the code ;-)

Cheers

Webko

<?php
	session_start();
	
	include_once('include/FX/FX.php');	// FX.php file
	include_once('include/db_config.php');	// DataBase Configuration File.
	$error = "";
	//If action set, perform database insert
	if (isset($_POST['ak'])) {
		$ak = $_POST['ak'];
		//Get parameters
		if  (isset($_POST['procCode'])&& $_POST['procCode'] != "") 
{ $procCode = $_POST['procCode'];	} else { $procCode = ""; }
		if  (isset($_POST['startTime'])&& $_POST['startTime'] != "") 
{ $startTime = $_POST['startTime'];	} else { $startTime = ""; }
		if  (isset($_POST['endTime'])&& $_POST['endTime'] != ""){ $endTime =  
$_POST['endTime'];	} else { $endTime = ""; }
		if  (isset($_POST['goalsInclude'])&& $_POST['goalsInclude'] != "") 
{ $goalsInclude = implode("\r", $_POST['goalsInclude']);	} else  
{ $goalsInclude = ""; }

		
		//Add new record
		$addProgressNotes = new FX($dbHost,$port,$dbType,$conType);
		$addProgressNotes -> setDBPassword($dbPass,$dbUser);
		$addProgressNotes -> setDBData($dbName,'Detail');
		$addProgressNotes -> AddDBParam('ProcCode', $procCode);
		$addProgressNotes -> AddDBParam('StartTime', $startTime);
		$addProgressNotes -> AddDBParam('EndTime', $endTime);
		$addProgressNotes -> AddDBParam('GoalsInclude', $goalsInclude);
		$addProgressNotesData = $addProgressNotes->FMNew();
//		echo "Contact Error: ".$addProgressNotesData['errorCode']."<br />";
	
	}


	//Find value lists
	$vlists=new FX($dbHost,$port,$dbType,$conType);
	$vlists -> setDBPassword($dbPass,$dbUser);
	$vlists -> SetDBData($dbName,'Detail', 'all');
	$vlistsResult=$vlists->FMView();
//	echo "Error".$vlistsResult['errorCode'];


	
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd 
">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="english"  
lang="english">
<head>
<title>NSMH Progress Notes</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
</head>
<body>
<table cellpadding="0" cellspacing="0">
	<tr>
		<td id="header">
			<h1>Add notes</h1>
<?php if ($error != "") { ?>
			<h2>Error: <?php echo $error; ?>
<?php } else { ?>
			<h2>Enter complete information, then click Submit</h2>
		</td>
	</tr>
	<tr>
		<td>
		<form name="addNotes" id="addNotes" action="index.php" method="post">
		<table cellpadding="0" cellspacing="0">
			<tr>
				<td class="dataLabel">ProcCode</td>
			</tr>
			<tr>
				<td class="dataInput">
				<select name="procCode">
					<option>H2105</option>
					<option value="">--</option>
					<option>H2105</option>
					<option>H0023</option>
					<option>H2105HT</option>
					<option>H2105U1</option>
					<option>H2105U2</option>
					<option>H2105U3</option>
					<option>H2105U5</option>
					<option>H0038</option>
					<option>90801</option>
					<option>99362</option>
					<option>99366</option>
					<option>90772</option>
					<option>General</option>	
				</select>
			</tr>
			<tr>
				<td class="dataLabel">StartTime</td>
			</tr>
			<tr>
				<td class="dataInput"><input type="text" name="startTime"  
size="15" /></td>
			</tr>
			<tr>
				<td class="dataLabel">EndTime</td>
			</tr>
			<tr>
				<td class="dataInput"><input type="text" name="endTime" size="15" / 
 ></td>
			</tr>
			<tr>
				<td class="dataLabel">GoalNumbers</td>
			</tr>
			<tr>
				<td class="dataInput">
<?php
	foreach($vlistsResult['valueLists']['GoalsInclude'] as $key => $value){
?>
         <input type="checkbox" name="goalsInclude[]" value="<?php  
echo $value; ?>" /><span class="dataLabel"><?php echo $value; ? 
 >&nbsp;&nbsp;&nbsp;</span>
<?php
	}
?>
				</td>
			</tr>

		</table>
		<input type="submit" name="ak"  
value="Submit">&nbsp;&nbsp;&nbsp;&nbsp;<input type="reset" name="ak"  
value="Clear">
		</form>
		</td>
	</tr>
</table>
<?php } ?>
</body>
</html>



More information about the FX.php_List mailing list