How to validate one element?s rows sum?

jmdc

Member
Hello,

I would like to know if it?s possible to have a php validation in the sum of one element.

So, imagine i have one element Yes/NO, wich values are "1" or "0".
And i have 4 rows:
Row 1:0
Row 2:1
Row 3:0
Row 4:0

If user edit row 2 to No wich is "zero", my validation should say that?s not possible because the row?s sum of this element should always be > 0.

Could you help me?

Thanks you.
 
I am writing this code, but it doesn?t work...what am i missing??

app = JFactory::getApplication();
$result = mysql_query('SELECT SUM(esc_familiasdet___DebitarFacturas_raw) AS value_sum FROM esc_familiasdet');
$row = mysql_fetch_assoc($result); $sum = $row['value_sum'];
if($sum == '0'){
return true;
}
else{
return false;
}
 
I forgot something...i just want to validate this form for this row?s user who is submitting the form, and not all the data?s rows...

Could you help me?

Thanks.
 
I have already read these wikis, but how can i sum these records like the sum button? What code to use and where do i have to put it? In "condition" or "php"?
thank you
 
  • Condition - A PHP expression which if returns false, means that the validation is not run.
  • PHP -PHP code to run.
    • If it returns 'true' then the validation is successful,
    • if it returns false then the validation fails.
    • The element's submitted value is found in the variable $data.
 
My problem is that i don?t know what code to put into Condition and PHP ? Could you help me,please?

Thank you.
 
What code i have to put in php for a calc element if i want to sum all rows from one element A? If you help me, i can after that a validation like "greatorlessthan" in the other element B.

Thank you.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top