format problem with numbers above 1000 !RESOLVED
Posted: Mon Jan 31, 2011 1:44 pm
Hi,
I have a problem with some script taking figures out of money fields from a mssql db.
it works fine as long as the number is below 1000. but as soon as it is higher than 1000 the system sets the number to 1 when adding it to another number...
e.g. 1038,40 -> 1 and not 1,03 or something like that but just 1
in one loop I would have
1026,45 + 29,50
when echoing these separately they show up as they should. when adding them, the result is 30,50 and it doesn't matter at what point in the script I add them...
I have a problem with some script taking figures out of money fields from a mssql db.
it works fine as long as the number is below 1000. but as soon as it is higher than 1000 the system sets the number to 1 when adding it to another number...
e.g. 1038,40 -> 1 and not 1,03 or something like that but just 1
in one loop I would have
1026,45 + 29,50
when echoing these separately they show up as they should. when adding them, the result is 30,50 and it doesn't matter at what point in the script I add them...
Code: Select all
$recordSet5 = &$conn->Execute('select curren from waehrungen where id= '.$curren);
$currenc = $recordSet5->fields['curren'];
$recordSet3 = &$conn->Execute('select auftrag_id, text, preis from translat where rechn = 1 and druck = 0 and kunde = '.$_POST["kunde"]);
$total = 0;
$total2 = 0;
$mwsttot = 0;
$mwsttot2 = 0;
$counter = 0;
while (!$recordSet3->EOF) {
$auftrag_id = $recordSet3->fields['auftrag_id'];
$text = $recordSet3->fields['text'];
$preis = $recordSet3->fields['preis'];
$preis = $preis;
$preis = number_format($preis,2);
$total = $total+$preis;
echo $total;
exit;
$total = number_format($total,2);
$preis = str_replace(",",";",$preis);
$preis = str_replace(".",",",$preis);
$preis = str_replace(";",".",$preis);
$counter = $counter+1;
$pdf->Cell(60,0,$auftrag_id,0,0,'L');
$pdf->Cell(60,0,$text,0,0,'L');
$pdf->Cell(30,0,$wpreis,0,0,'R');
$pdf->Cell(30,0,$preis.' '.$currenc,0,0,'R');
$pdf->Ln(4);
$recordSet3->MoveNext();
}