I agree with the suggestion below strip the character and typecast it if
necessary. In JSP I think you can convert it to a number and then typecast it.
In PHP, I think the principles might be the same.

In addition, it might be a good idea to restrict the columns that require
computation to a numeric value rather than a string because you can always add
the comma later when totalling it for display. It might also be more efficient
for sorting and doing sums, totals etc from your select statements.(i.e. select
sum() total()) since computers are inherently better at handling numbers than
strings (though I could be mistaken)

So if its possible for you to redeclare the table definition then that will be
great.

Good luck

[EMAIL PROTECTED] wrote:

> It could be best to parse and remove ',' from both of them first before
> calculation...
>
> R.B.Roa
> PhilCom Corporation
> Tel. No. 858-xxxx
> Mobile No. (63) (919-xxxxxxx)
>
>         -----Original Message-----
>         From:   delz [SMTP:[EMAIL PROTECTED]]
>         Sent:   Thursday, April 18, 2002 1:50 PM
>         To:     [EMAIL PROTECTED]
>         Subject:        Re: Math Computations
>
>         Hi All,
>
>         How do I make calculations in php or mysql if the value has a comma
> like
>         2,000 + 32,000 = 34,000. I have a problem
>         calculating if one of my values has a comma. It doesn't display the
> right
>         output. I'll appreciate anyone who can
>         help me with this.
>
>         Thanks.
>
>         Delz.
>
>         ----- Original Message -----
>         From: "Adam Alkins" <[EMAIL PROTECTED]>
>         To: "delz" <[EMAIL PROTECTED]>
>         Cc: <[EMAIL PROTECTED]>
>         Sent: Thursday, April 11, 2002 5:44 PM
>         Subject: Re: Math Computations
>
>         > Something like
>         >
>         > <?
>         >
>         > $db = mysql_connect("localhost","database_user","password");
>         > mysql_select_db (database_name);
>         >
>         > $query = "SELECT * FROM table_name";
>         > $result = mysql_query($query);
>         >
>         >
>         > echo "Computers | Department | Price Per PC | Total Amount<br>";
>         >
>         > while ($row = mysql_fetch_row($result)){
>         >     $subtotal=$row[0]*$row[2];
>         >     $total+=$subtotal;
>         >     echo "$row[0] | $row[1] | $row[2] | $subtotal<BR>";
>         >     $comptotal+=$row[0];}
>         > }
>         > echo "$comptotal $total";
>         >
>         > ?>
>         >
>         > Obviously format it into a table would make sense, e.t.c.
>         >
>         > Adam
>         > ----- Original Message -----
>         > From: "delz" <[EMAIL PROTECTED]>
>         > To: <[EMAIL PROTECTED]>
>         > Sent: Thursday, April 11, 2002 5:29 AM
>         > Subject: Math Computations
>         >
>         >
>         > > Hi,
>         > >
>         > > I have this table that looks like this
>         > >
>         > > Computers | Department | Price per PC | TotalAmount |
>         > >     15          |   Marketing | $500.00        |
> |
>         > >      5          |   Purchasing | $ 300.00      |
> |
>         > >
>         > > I want this table to display the total price wherein Computer *
> Price
>         Per
>         > PC
>         > > = TotalAmount
>         > > and want to display the total no. of computer and the OverAll
>         TotalAmount.
>         > >
>         > > I want the output to look like this
>         > >
>         > > Computers | Department | Price per PC | TotalAmount |
>         > >     15          |   Marketing | $500.00        | $ 7500.00     |
>         > >      5          |   Purchasing | $ 300.00      |  $ 900.00
> |
>         > > ---------
> -----------
>         > >   20                                                          $
> 8400.00
>         > >
>         > > Can anyone help me how to do this in mysql or php. I will surely
>         > appreciate
>         > > any help I
>         > > can get.
>         > >
>         > > Thanks.
>         > >
>         > > Delz
>         > >
>         > >
>         > >
> ---------------------------------------------------------------------
>         > > Before posting, please check:
>         > >    http://www.mysql.com/manual.php   (the manual)
>         > >    http://lists.mysql.com/           (the list archive)
>         > >
>         > > To request this thread, e-mail
> <[EMAIL PROTECTED]>
>         > > To unsubscribe, e-mail
>         <[EMAIL PROTECTED]>
>         > > Trouble unsubscribing? Try:
> http://lists.mysql.com/php/unsubscribe.php
>         > >
>         > >
>         > >
>         >
>         >
>         >
>         >
> ---------------------------------------------------------------------
>         > Before posting, please check:
>         >    http://www.mysql.com/manual.php   (the manual)
>         >    http://lists.mysql.com/           (the list archive)
>         >
>         > To request this thread, e-mail
> <[EMAIL PROTECTED]>
>         > To unsubscribe, e-mail
>         <[EMAIL PROTECTED]>
>         > Trouble unsubscribing? Try:
> http://lists.mysql.com/php/unsubscribe.php
>
>
> ---------------------------------------------------------------------
>         Before posting, please check:
>            http://www.mysql.com/manual.php   (the manual)
>            http://lists.mysql.com/           (the list archive)
>
>         To request this thread, e-mail <[EMAIL PROTECTED]>
>         To unsubscribe, e-mail
> <[EMAIL PROTECTED]>
>         Trouble unsubscribing? Try:
> http://lists.mysql.com/php/unsubscribe.php
>
> ---------------------------------------------------------------------
> Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail <[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to