alin19 Posted November 8, 2007 Share Posted November 8, 2007 <?php if($_SERVER['REQUEST_METHOD'] == 'POST') { $a = $_POST['unu']; $b = $_POST['doi']; $x = $a*$b; } ?> <html> <body BACKGROUND="mapa2.jpg"> <form name="check" method="post"> </br></br></br></br></br></br> <table width="304" border="2" cellpadding="0" cellspacing="2" align="center"> <!--DWLayoutTable--> <tr><td id="sapte"/></td></tr> <tr> <td border="0">test</td><td valign=""align="center" ><font color="red" size="3">Ultimul Pret de Inchidere</font></td> <td width="304" height="79" valign="" align="center"> <input name="unu" type="text" id="unu" /> </td><td> </tr> <tr><td border="0">test</td> <td valign=""><font color="red" size="3" align="center">Actiuni gratuite de primit</font></td> <td height="86" valign="" align="center" ><input name="doi" type="text" id="doi" /></td> </tr> <tr><td border="0">test</td> <td valign="" align="center" ><font color="red" size="3" align="green"></font></td> <td height="86" valign="" align="center"><input type="submit" name="CALCULEAZA" value="CALCULEAZA" /></td> </tr> <tr><td border="0">test</td> <td valign="" align="center" ><font color="red" size="3" align="green">Pret ex-dividend</font></td> <td height="35" valign="" align="center"><font color="green" size="8" ><?php if(isset($x)) { echo $x; } ?> </font></td> </tr> </table> </form> </html> i need x to write only 2 decimals, how can i do that? Quote Link to comment Share on other sites More sharing options...
MadTechie Posted November 8, 2007 Share Posted November 8, 2007 <?php $number = 1234.5678; $format_number = number_format($number, 2, '.', ''); echo $format_number; //1234.56 ?> so <?php $a = $_POST['unu']; $b = $_POST['doi']; $x = number_format(($a*$b), 2, '.', ''); ?> Quote Link to comment Share on other sites More sharing options...
alin19 Posted November 8, 2007 Author Share Posted November 8, 2007 10x it works Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.