Re: Seems Simple enough
| From: | Christopher J. Crane | Date: | Mon, 26 Jan 2004 17:29:48 +0000 |
| Subject: | Re: Seems Simple enough | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-175790@lists.php.net to get a copy of this message | ||
Ok the problem seems to me, the format. I think that once I have the format
changed to include a comma seperation for thousands. I think at that point,
it is no longer a true number, so PHP deals with it differently.
"Christopher J. Crane" <ccrane@ikon.com> wrote in message
news:20040126171005.79090.qmail@pb1.pair.com...
> Good Question on the looking though all rows. I never wrote code looking
at
> just that one code and getting the variable from the column. That is why I
> limited the query to one "LIMIT 1". I guess it is just me pasting code
from
> my other applications and not checking it out.
>
> To the original problem, it all hinges on me changing the format of
> $Balance. If I remove the line " $Balance =
> number_format($SummaryField["Balance"],2,'.',','); "
> and replace it with " $Balance = $SummaryField["Balance"]; " it works
fine.
>
> "Stuart" <lists@sharedserver.net> wrote in message
> news:40154773.5040108@sharedserver.net...
> > Christopher J. Crane wrote:
> > > This does not ...
> > > $SummaryResults = mysql_query("SELECT * FROM Accounting WHERE
> > > UserID='$UserID' LIMIT 1") or die("Invalid query");
> > > while($SummaryField = mysql_fetch_array($SummaryResults)) {
> > > $Balance =
> > > number_format($SummaryField["Balance"],2,'.',',');
> > > }
> >
> > Display $Balance here. Just do a print $Balance. Something is wrong
> > there, not below.
> >
> > While we're at it, why are you looping through all of the rows setting
> > $Balance each time? If it's only going to return one row, get that one
> > row and use it!!
> >
> > > if($Balance >= 10001) { echo "<font
> > > color=\"green\">\$$Balance</font><br>\n"; }
> > > elseif($Balance <= 9999) { echo "<font
> > > color=\"red\">\$$Balance</font><br>\n"; }
> > > else { echo "<font
> > > color=\"purple\">\$$Balance</font><br>\n"; }
> >
> > --
> > Stuart