AnsweredAssumed Answered

CWP PHP and value list

Question asked by khardy.dsi on Aug 20, 2012
Latest reply on Aug 21, 2012 by Mike_Mitchell

I have a very simple database that I use CWP to log users in and out of thier desk. I have two fields (In or Out, Will Return) both have simple fixed value lists attached to then. I can locate the php functions for the value list (getValueListTwoFields) but cannot locate how to implement the list on the CWP page. I have attached the php file from the sample that i have modified to produce my page. I am seeking assistance on how to display the choices on the website.

 

 

<html>

<?php

/**

* viewRecord.php

*

* Copyright © 2005-2006, FileMaker, Inc. All rights reserved.

* NOTE: Use of this source code is subject to the terms of the FileMaker

* Software License which accompanies the code. Your use of this source code

* signifies your agreement to such license terms and conditions. Except as

* expressly granted in the Software License, no other copyright, patent, or

* other intellectual property license or right is granted, either expressly or

* by implication, by FileMaker.

*

* Example PHP script to illustrate how to view a particular record in a database using PHP API.

*

* Requirements:

* 1. Working FileMaker Server installation

* 2. 'InOut' database hosted in FileMaker Server

*

*/

 

// 22 Include FileMaker API

require_once ('FileMaker.php');

 

 

// Create a new connection to InOut database.

// Location of FileMaker Server is assumed to be on the same machine,

// thus we assume hostspec is api default of 'http://localhost' as specified

// in filemaker-api.php.

// If FMSA web server is on another machine, specify 'hostspec' as follows:

// $fm = new FileMaker('InOut', localhost;

$fm = new FileMaker();

$fm->setProperty('database', 'InOut');

$fm->setProperty('hostspec', 'localhost');

$fm->setProperty('username', 'webuser');

$fm->setProperty('password', 'webuser');

 

 

// Since we're passed in recid via param (i.e. viewRecord.php?recid=n), use

// FileMaker::getRecordById() to directly get record object with recid accessed

// via $_GET[] array

$record = $fm->getRecordById('Contact Status', $_GET['recid']);

 

 

if (FileMaker::isError($record)) {

echo "<body>Error: " . $record->getMessage(). "</body>";

exit;

}

// 46 Script to call in status

$instatus = $fm->newPerformScriptCommand('Contact Status', 'Status to In');

// $result = $newPerformScript->execute();

$scripts = $fm->listScripts();

?>

</title>

<!-- declare charset as UTF-8 -->

<meta http-equiv="content-type" content="text/html; charset=UTF-8">

<link rel="stylesheet" href="style2.css">

</head>

<body>

<form action="handleForm.php" method="post">

<table>

<tr><th id="table-title" colspan="3">Ashe County DSS In/Out</th></tr>

<tr><th>Last Name</th><td><?php echo $record->getField('Last'); ?></td></tr>

<tr><th>First Name</th><td><?php echo $record->getField('First'); ?></td></tr>

<tr><th>Department</th><td><?php echo $record->getField('Department'); ?></td></tr>

<tr><th>Office Phone</th><td><?php echo $record->getField('Work Phone'); ?></td></tr>

<tr><th>Status In/Out</th><td><input type="text" size="80" name="Status" value="<?php echo $record != null ? $record->getField('Status') : null; ?>"></td></tr>

<tr><th>Return Time</th><td><input type="text" size="80" name="Will Return" value="<?php echo $record != null ? $record->getField('Will Return') : null; ?>"></td></tr>

<tr><th>Notes</th><td><input type="text" size="80" name="Notes" value="<?php echo $record != null ? $record->getField('Notes') : null; ?>"></td></tr>

<tr><th>Last Updated</th><td><?php echo $record->getField('Status Updated'); ?></td></tr>

 

 

<tr><td colspan=2>

<?php

// output OK (submit) and Cancel buttons

if ($record != null) {

// if we're editing a record, submit button is labeled "OK"

?>

<input type="hidden" name="recid" value="<?php echo $record->getRecordId(); ?>">

<button type="submit" name="action" value="edit">OK</button>

<?php

} else {

// otherwise, submit button is "Create New Record"

 

 

?>

<button type="submit" name="action" value="edit">Create New Record</button>

<?php

}

?>

</td></tr>

</table>

</form>

</body>

</html>

Outcomes