Re: Seems Simple enough
| From: | Christopher J. Crane | Date: | Mon, 26 Jan 2004 17:09:46 +0000 |
| Subject: | Re: Seems Simple enough | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-175787@lists.php.net to get a copy of this message | ||
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