[PHP-DB] Rounding numbers again.

2002-03-01 Thread Jennifer Downey

Thanks for answering my question I understand rounding now.

My next question is why the script will work like this:

$bank_points= $ret;
$interest = .095;
$months = 12;
$weeks = 52;
$days=365;


$query="SELECT  bank_points FROM wt_users WHERE uid={$session["uid"]}";
$ret = mysql_query($query);
while(list($bank_points)=
mysql_fetch_row($ret))
 
$yearly_interest=$bank_points * $interest;
$round_yearly= round($yearly_interest);
print("Your yearly interest is : $round_yearly Gold Pieces");

$daily_interest=$round_yearly / $days;
$round_daily = round($daily_interest);
print("Your daily interest is : $round_daily Gold Pieces");

$query = "UPDATE wt_users set bank_points = bank_points + $round_daily WHERE 
uid={$session["uid"]}";
$result = mysql_query($query);

and not like this.

$bank_points = $ret;
$interest = .095;
$months = 12;
$weeks = 52;
$days=365;

$yearly_interest=$bank_points * $interest;
$round_yearly= round($yearly_interest);


$daily_interest=$round_yearly / $days;
$round_daily = round($daily_interest);

$query = "UPDATE wt_users set bank_points = bank_points + $round_daily";
$ret = mysql_query($query);

or this.

$query = "UPDATE wt_users set bank_points = bank_points + $round_daily";
$ret = mysql_query($query);

$bank_points = $ret;
$interest = .095;
$months = 12;
$weeks = 52;
$days=365;

$yearly_interest=$bank_points * $interest;
$round_yearly= round($yearly_interest);


$daily_interest=$round_yearly / $days;
$round_daily = round($daily_interest);

$query = "UPDATE wt_users set bank_points = bank_points + $round_daily";
$ret = mysql_query($query);

If I use the users session id then it works fine. With the query all I'm doing is 
updating ALL users bank_points right? I want to use cron to update all users at 
midnight.



Thanks again
Jennifer Downey




[PHP-DB] Rounding numbers

2002-03-01 Thread Jennifer Downey

Hi again,

Would someone show me how to round numbers:


$bank_points= $ret;
$interest = .095;
$months = 12;
$weeks = 52;
$days=365;

$query="SELECT  bank_points FROM wt_users WHERE uid={$session["uid"]}";
$ret = mysql_query($query);
while(list($bank_points)=
mysql_fetch_row($ret))

$yearly_interest=$bank_points * $interest;
print("Your yearly interest is : $yearly_interest");

$daily_interest=$yearly_interest / $days;
$round_daily_interest = round($daily_interest);
print("Your daily interest is : $daily_interest");

Thanks
Jennifer Downey



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php