mcmuney Posted December 4, 2010 Share Posted December 4, 2010 I'd like to perform 2 tasks: First, get a list of users who have not logged in for 30 days. Then, deduct some points as a penalty. This is what I have so far: $sec=30*86400; $curr_time=time(); $maxtime=$curr_time-$sec; $result = mysql_query("SELECT scm_mem_id FROM sc_member WHERE (scm_lastlogin < '$maxtime') ORDER BY scm_lastlogin") ; while($row = mysql_fetch_row($result)) { $member = $row[0]; //-------------------------- DEDUCT POINTS -------------------------------- $points = ?; // need to pull existing points (field: scm_points) from the above SELECT statement and deduct 10% (rounded) $time_=time(); $sql_c = "INSERT INTO sc_coins_asset (`type_id`,`mem_id`,`from/to_mem_id`,`date_added`,`value`) VALUES(9,$member,8,'".$time_."',-".$points.")"; $db->insert_data($sql_c); } Quote Link to comment https://forums.phpfreaks.com/topic/220637-having-trouble-with-arrays/ Share on other sites More sharing options...
phpretard Posted December 4, 2010 Share Posted December 4, 2010 Maybe this //-------------------------- DEDUCT POINTS -------------------------------- $point_total = $row['scm_points']; $point_minus = $point_total * .1; $points = round($point_minus); echo "Begining: $point_total <br />"; echo "Minus 10% Rounded: $points"; // need to pull existing points (field: scm_points) from the above SELECT statement and deduct 10% (rounded) Quote Link to comment https://forums.phpfreaks.com/topic/220637-having-trouble-with-arrays/#findComment-1142861 Share on other sites More sharing options...
mcmuney Posted December 4, 2010 Author Share Posted December 4, 2010 Something isn't quite right with the array. As you can see: $member = $row[0] //shows scm_mem_id, but if I modify this to either $row['scm_mem_id'] or $row[0]['scm_mem_id'] it doesn't show it How can I pull both scm_mem_id and scm_points and show them both separately? Quote Link to comment https://forums.phpfreaks.com/topic/220637-having-trouble-with-arrays/#findComment-1142865 Share on other sites More sharing options...
phpretard Posted December 4, 2010 Share Posted December 4, 2010 post this: echo "<pre>". print_r(your array name here) ."</pre>"; Quote Link to comment https://forums.phpfreaks.com/topic/220637-having-trouble-with-arrays/#findComment-1142866 Share on other sites More sharing options...
jcbones Posted December 4, 2010 Share Posted December 4, 2010 Change the query: //from $result = mysql_query("SELECT scm_mem_id FROM sc_member WHERE (scm_lastlogin < '$maxtime') ORDER BY scm_lastlogin") ; //to $result = mysql_query("SELECT scm_mem_id, scm_points FROM sc_member WHERE (scm_lastlogin < '$maxtime') ORDER BY scm_lastlogin") ; //change: $points = ?; // need to pull existing points (field: scm_points) from the above SELECT statement and deduct 10% (rounded) //to $points = $row[1] - round($row[1] * .10); //Find 10% of scm_points, and subtract it from points. Rounded of course. Quote Link to comment https://forums.phpfreaks.com/topic/220637-having-trouble-with-arrays/#findComment-1142991 Share on other sites More sharing options...
laffin Posted December 4, 2010 Share Posted December 4, 2010 question is why are u using insert? if the record is already in the db...... Quote Link to comment https://forums.phpfreaks.com/topic/220637-having-trouble-with-arrays/#findComment-1143018 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.