This topic is locked
[SOLVED]

 Do not allow it to add a new value if nonzero

11/3/2013 12:37:45 AM
PHPRunner General questions
J
joiresende author

I have two fields in which the subtraction of the least field1 field2 must be equal to (0) zero. How do I not let add to the database if the total is greater than zero.
example:
if

field1 - field2 = 0

return true

if

field1 - field2 <> 0

return false

C
cgphp 11/3/2013
if(abs($values['field1'] - $values['field2']) > 0)

{

$message = 'Difference must be 0';

return false;

}


Replace field1 and field2 with the real names of the fields.

J
joiresende author 11/3/2013

hello

I put in´:

"before record add"?

C
cgphp 11/3/2013

Yes, add the code there.