Jump to content

Recommended Posts

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);
}

 

 

Link to comment
https://forums.phpfreaks.com/topic/220637-having-trouble-with-arrays/
Share on other sites

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)

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?

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.