后台会员列表增加USER_RANK如何用ajax快捷编辑

2016-07-07 14:55 来源:www.chinab4c.com 作者:ecshop专家



因为有需要,把USER_RANK信息调出来了,想和EMAIL一样可以快捷编辑,弄了好多天没搞好
参考EMAIL的写法弄了一个方法,但是还差一步,就是同步更新到数据库这一步有问题,请教各位大虾帮忙,谢谢啦!网上找资料找了好久没找到合适的办法:
user.php文件里面:
EMAIL编辑的原方法:
  1. /*------------------------------------------------------ */
  2. //-- 编辑email
  3. /*------------------------------------------------------ */
  4. elseif ($_REQUEST['act'] == 'edit_email')
  5. {
  6. /* 检查权限 */
  7. check_authz_json('users_manage');

  8. $id = empty($_REQUEST['id']) ? 0 : intval($_REQUEST['id']);
  9. $email = empty($_REQUEST['val']) ? '' : json_str_iconv(trim($_REQUEST['val']));

  10. $users =& init_users();

  11. $sql = "SELECT user_name FROM " . $ecs->table('users') . " WHERE user_id = '$id'";
  12. $username = $db->getOne($sql);


  13. if (is_email($email))
  14. {
  15. if ($users->edit_user(array('username'=>$username, 'email'=>$email)))
  16. {
  17. admin_log(addslashes($username), 'edit', 'users');
  18. make_json_result(stripcslashes($email));
  19. }
  20. else
  21. {
  22. $msg = ($users->error == ERR_EMAIL_EXISTS) ? $GLOBALS['_LANG']['email_exists'] : $GLOBALS['_LANG']['edit_user_failed'];
  23. make_json_error($msg);
  24. }
  25. }
  26. else
  27. {
  28. make_json_error($GLOBALS['_LANG']['invalid_email']);
  29. }
  30. }
复制代码


参照EMAIL,写出USER_RANK方法:
  1. /*------------------------------------------------------ */
  2. //-- 编辑USER_RANK
  3. /*------------------------------------------------------ */
  4. elseif ($_REQUEST['act'] == 'edit_user_rank')
  5. {
  6. /* 检查权限 */
  7. check_authz_json('users_manage');

  8. $id = intval($_REQUEST['id']);
  9. $user_rank = json_str_iconv(trim($_REQUEST['val']));

  10. $users =& init_users();

  11. $sql = "SELECT user_name FROM " . $ecs->table('users') . " WHERE user_id = '$id'";
  12. $username = $db->getOne($sql);

  13. if ($users->edit_user(array('username'=>$username, 'user_rank'=>$user_rank)))
  14. {
  15. make_json_result(stripslashes($user_rank));

  16. }

  17. }
复制代码

修改后:




刷新后: