$result =0;
if ($id_marca!=1) {
$result = $result + $vl_max*$pares; // id_marca = 22 [ 38 pares * 1.451 = 55.14 ]
}
elseif ($id_marca=='1'){
$result = $result + $vl_min*$pares; ///id_marca = 1 [ 36 pares * 1.392 = 50.15 ]
}
else {
$result ='';
}
$result;
Hello, I need Help.
with above script, I´m receiving the $result two values (55.14 & 50.15).
So, I want to the sum the $result = (105.29).
Thank you!!
jorgeftz 0 Newbie Poster
Recommended Answers
Jump to PostIf you want both values totalled then you don't want the IF/ELSE structure because that is the reason only one calculation is running (whether $id_marca equals 1 or not).
Depending on your exact requirements you would be better off to store each calculation into two different result variables and then …
Jump to PostYou still have the if/else clause in there.
If $id_marca != 1 the resultMax is calculated otherwise it is 0.
If $id_marca = 1 then resultMin is calculated otherwise it is 0;Take out that entire if/else block and just have the two calcualtion lines. Then $resultMax and $resultMin will …
Jump to PostThat's way off.
$sumresults = 0; //start loop if(!in_array($id_marca, array(1,2,23,24,27,31,52))) { $sumresults += $vl_min * $pares; } //end loop
Not that I have a clue about what you're trying to do though :(
Jump to PostIt would be much easier if you showed an sql dump of your relevant tables and some sample data in each.
Jump to PostIt would be much easier if you showed an sql dump of your relevant tables and some sample data in each.
I meant the table structures and a couple of records for each...
e.g.
TABLE1id | field1 | field2 | field31 | value1 | …
All 19 Replies
hericles 289 Master Poster Featured Poster
jorgeftz 0 Newbie Poster
hericles 289 Master Poster Featured Poster
jorgeftz 0 Newbie Poster
hericles 289 Master Poster Featured Poster
jorgeftz 0 Newbie Poster
hericles 289 Master Poster Featured Poster
jorgeftz 0 Newbie Poster
jorgeftz 0 Newbie Poster
hericles 289 Master Poster Featured Poster
jorgeftz 0 Newbie Poster

diafol
jorgeftz 0 Newbie Poster

diafol
jorgeftz 0 Newbie Poster
jorgeftz 0 Newbie Poster
jorgeftz 0 Newbie Poster
jorgeftz 0 Newbie Poster

diafol
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.