Forum Moderators: coopster

Message Too Old, No Replies

Multiple Negative numbers on a page

Flips to positive

         

johnnydequino

7:42 pm on Sep 16, 2004 (gmt 0)

10+ Year Member



Whenever I have the "same" negative number for a row show up multiple times on a page, it does not seem to work correctly.

Get This <a href="<?=$row->offerurl?>"><?=$row->manufacturer?>&nbsp;<?=$row->phonemodel?> Phone <strong>
<? if ($row->rebateprice < 0.00)
{$row->rebateprice = number_format(abs($row->rebateprice),2);
print "Not just free, you make:&nbsp;<font color='#CC0000'>$&nbsp;$row->rebateprice</font>"; }
elseif ($row->rebateprice == 0.00)
{$row->rebateprice = "$row->rebateprice";
print "&nbsp;Get it For <u>Free</u>! Cost:&nbsp;<font color='#CC0000'>$&nbsp;$row->rebateprice</font>"; }
elseif ($row->rebateprice > 0.00)
{$row->rebateprice = "$row->rebateprice";
print "Cost:&nbsp;&nbsp;$<font color='#000000'>$row->rebateprice</font>"; }?>

I have the above code on my php page three times. When the price is == 0, everything works fine.

When the price is > 0, everything works fine.

When the prices is < 0, The first result says "Not just free, you make: $35.

The second and third result on the page, for the same value, says: Cost: $35.

Am I missing something? It only happens with the scenerio is less than 0.

Thanks for your help -!

jd

Timotheos

4:29 am on Sep 17, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you're repeating this code then the first time through the rebate price is made positive by this line

if ($row->rebateprice < 0.00)
{$row->rebateprice = number_format(abs($row->rebateprice),2);
print "Not just free, you make:&nbsp;<font color='#CC0000'>$&nbsp;$row->rebateprice</font>"; }

From then on $row->rebateprice will be positive

Maybe do it like this
if ($row->rebateprice < 0.00)
{print "Not just free, you make:&nbsp;
<font color='#CC0000'>$&nbsp;".number_format(abs($row->rebateprice),2)."</font>"; }

johnnydequino

1:16 pm on Sep 18, 2004 (gmt 0)

10+ Year Member



Timotheos - you rock! This was exactly the problem. I appreciate all your help.

jd