Rounding numbers again.

From: Date: Sat, 02 Mar 2002 02:42:22 +0000
Subject: Rounding numbers again.
Groups: php.db 
Request: Send a blank email to php-db+get-17408@lists.php.net to get a copy of this message
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("<BR>Your yearly interest is : $round_yearly Gold Pieces"); $daily_interest=$round_yearly / $days; $round_daily = round($daily_interest); print("<BR>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

« previous php.db (#17408) next »