This topic is locked

adjust content of field to suit another field

6/5/2008 10:25:31 AM
PHPRunner General questions
T
thesofa author

Hi, I have to setup a report writing database to allow online reporting about kids. The teachers cannot type more than one or two words, so the fields will be multiple choice selections from a list.

The staff would like this to appear personalised so if it is a girl, they would like it to read like this

<'firstname'> has made good inroads into curing 'her' drink problems, 'she' will do better to leave 'her' drink at home

<'firstname'> has made good inroads into curing 'his' drink problems, 'he' will do better to leave 'his' drink at home

I realise I can have 2 sets of statements from which to chose, but that is not elegant, I would rather have an additional field of `gender` in the pupil table, and then have an `if` statement somewhere to decide if it is `he `or `she` and `his` or `hers`.

Has anyone had to do this or anything similar and is anyone prepared to share ideas please?

Many thanks

J
Jane 6/7/2008

Hi,
if this text is stored in one of your fields use custom "View as" format for this field.

Here is a sample:

global $data;

if ($data["gender"]=="female")

$value = $data["FirstName"]." has made good inroads into curing her drink problems, she will do better to leave her drink at home";
if ($data["gender"]=="male")

$value = $data["FirstName"]." has made good inroads into curing his drink problems, he will do better to leave his drink at home";

T
thesofa author 7/7/2008

Spot on, as usual, many thanks Jane.