1
<html> <head>   <title>Rough Diamond 
 Information</title> </head> 
<body>

<?php

mysql_connect("localhost","root","");
mysql_select_db("basic");
$order = "select * from calculator ";
$result=mysql_query($order);

echo "Rough Diamonds Information:&nbsp; &nbsp; &nbsp; &nbsp;";
echo "<a href='home.html'>Go to main page <br><br>";
?>


<table border="1" style="width:50%">
<tr>
    <th><b>ID</b></th>
    <th><b> Name</b></th>
    <th><b> Total Rough Weight</b></th>
    <th><b>One Carat Price</b></th>
    <th><b>Dollar Rate</b></th>
    <th><b>Payment Days</b></th>
    <th><b>Total Payment</b></th>
</tr>

<?php while($row = mysql_fetch_array($result) ) {

echo "<tr>
<td>".$row['id']."</td>
<td>".$row['name']."</td>
<td>".$row['total_wt']."</td>
<td>".$row['crt_price']."</td>
<td>".$row['dollar_rate']."</td>
<td>".$row['pay_day']."</td>
<td>".$row['total_price']."</td>
</tr>";} ?>

</body>
</html>
Disha V.
  • 1,834
  • 1
  • 13
  • 21
John
  • 23
  • 5

4 Answers4

2

Use number_format($number);.

View http://php.net/manual/en/function.number-format.php

Ashwini Agarwal
  • 4,828
  • 2
  • 42
  • 59
1

Use money_format to format Currency like this.

$amount = '300000';
setlocale(LC_MONETARY, 'en_IN');
$amount = money_format('%!i', $amount);
echo $amount; // 3,00,000.00

Here is the helping link Link

Community
  • 1
  • 1
Ashish Choudhary
  • 2,004
  • 1
  • 18
  • 26
1

number_format will work for you

number_format($row['number'],0);
Andrew
  • 4,443
  • 5
  • 33
  • 75
0

create a function and display the number as follows

function moneyFormatIndia($num){
    $explrestunits = "" ;
    if(strlen($num)>3){
        $lastthree = substr($num, strlen($num)-3, strlen($num));
        $restunits = substr($num, 0, strlen($num)-3); // extracts the last three digits
        $restunits = (strlen($restunits)%2 == 1)?"0".$restunits:$restunits; // explodes the remaining digits in 2's formats, adds a zero in the beginning to maintain the 2's grouping.
        $expunit = str_split($restunits, 2);
        for($i=0; $i<sizeof($expunit); $i++){
            // creates each of the 2's group and adds a comma to the end
            if($i==0)
            {
                $explrestunits .= (int)$expunit[$i].","; // if is first value , convert into integer
            }else{
                $explrestunits .= $expunit[$i].",";
            }
        }
        $thecash = $explrestunits.$lastthree;
    } else {
        $thecash = $num;
    }
    return $thecash; // writes the final format where $currency is the currency symbol.
}

<?php while($row = mysql_fetch_array($result) ) {

echo "<tr>
<td>".$row['id']."</td>
<td>".$row['name']."</td>
<td>".$row['total_wt']."</td>
<td>".$row['crt_price']."</td>
<td>".$row['dollar_rate']."</td>
<td>".$row['pay_day']."</td>
<td>".moneyFormatIndia($row['total_price'])."</td>
</tr>";} ?>
Gunasegar
  • 161
  • 1
  • 9