This topic is locked

adding values from custom fields

6/16/2010 1:31:28 PM
PHPRunner General questions
T
tekhead2004 author

Hi all,
I have two custom fields in my list page. I Need to take the value from both fields and add them to each other in a third custom field.
For example:
Custom Field 1

$result = mysql_query("select clarify_tickets_percent as clarifypercent from variables");

if (!$result) {

echo 'Could not run query: ' . mysql_error();

exit;

}

$row = mysql_fetch_row($result);

$value = $row[0]*$data["clarify"];


Custom Field 2

$result = mysql_query("select clarify_tickets_hours as clarifyhours from variables");

if (!$result) {

echo 'Could not run query: ' . mysql_error();

exit;

}

$row = mysql_fetch_row($result);

$value = $row[0]*$data["clarify"];


Now I need to take the first custom field 1 value and add custom field 2 value, and display it in field 3.
Does anybody have an idea on how I could do this?

A
ann 6/17/2010

Hi,
you can make field 3 as custom field also. Here is a sample code:

$result = mysql_query("select clarify_tickets_percent as clarifypercent, clarify_tickets_hours as clarifyhours from variables");

if (!$result) {

echo 'Could not run query: ' . mysql_error();

exit;

}

$row = mysql_fetch_row($result);

$value = ($row[0]+$row[1])*$data["clarify"];