Jump to content

Recommended Posts

Here is my code

 

if(isset($_SESSION['admin']) || $authorized || isset($_SESSION['mod']))
{
  $ids = implode(', ', $_POST['post']);
  $error = false;
  foreach($_POST['post'] as $thread)
  {
    if(!is_numeric($thread))
    {
      $error = true;
      break;
    }
  }
  if(!$error)
  {
switch($_POST['action'])
{
    case 'delete':
    $get_poster = mysql_query("SELECT author FROM posts WHERE id IN ($ids)");
    $action_lower = mysql_query("UPDATE users SET dp = dp - 0.005 WHERE id IN ($get_poser)");     

    if(mysql_query("DELETE FROM {$prefix}posts WHERE id IN ($ids)"))
    {
      echo '<p>Post(s) successfully deleted. <a href="index.php">Back to forum</a>.</p>';
    }
    break;
    default:
    echo '<p>You have not selected an action. <a href="index.php">Click Here</a> to go to the forum index</p>';
  }
  }
  else
  {
    echo '<p>You have chosen invalid IDs. Please choose new ones <a href="index.php">here</a>.';
  }
}
else
{
  echo '<p>You need to be logged in as an administrator or moderator to do this.</p><p><a href="login.php">Click Here</a> to log in.';
}

 

As you see, I'm trying to get all the authors for each post selected, which is $ids. How would I make it so it updates every users points to be - 0.005? - I'm trying to do that at $action_lower

Link to comment
https://forums.phpfreaks.com/topic/205362-updating-donator-points-to-be-lower/
Share on other sites

You need to explain better then, because your code really doesn't make any sense. You're selecting the author's names and then comparing it against the id column.. The ids of the posts selected should correspond to the ids of the rows you want to update, no?

You need to explain better then, because your code really doesn't make any sense. You're selecting the author's names and then comparing it against the id column.. The ids of the posts selected should correspond to the ids of the rows you want to update, no?

 

No.

 

1) A moderator selects one or multiple posts.

2) They click "GO"

3) $ids is basically getting all or one of the posts selected

4) I'm trying to extract the info for EACH post selected

 

   $get_poster = mysql_query("SELECT author FROM posts WHERE id IN ($ids)");

 

5) I'm trying to update the points for each post author (basically getting all of the authors for each post in $get_poster) using this mysql_query:

 

    $action_lower = mysql_query("UPDATE users SET dp = dp - 0.005 WHERE id IN ($get_poser)"); 

Oh, sorry I didn't realize that you were dealing with two different tables. So the author column on the posts table corresponds to the id column on the users table?

 

UPDATE users SET dp = dp - 0.005 WHERE id IN (SELECT author FROM posts WHERE id IN ($ids))

Oh, sorry I didn't realize that you were dealing with two different tables. So the author column on the posts table corresponds to the id column on the users table?

 

UPDATE users SET dp = dp - 0.005 WHERE id IN (SELECT author FROM posts WHERE id IN ($ids))

 

Parse error: syntax error, unexpected T_STRING in /home/hero/public_html/forums/post_config.php on line 110

 

if(isset($_SESSION['admin']) || $authorized || isset($_SESSION['mod']))
{
  $ids = implode(', ', $_POST['post']);
  $error = false;
  foreach($_POST['post'] as $thread)
  {
    if(!is_numeric($thread))
    {
      $error = true;
      break;
    }
  }
  if(!$error)
  {
switch($_POST['action'])
{
    case 'delete':
    if(mysql_query("DELETE FROM {$prefix}posts WHERE id IN ($ids)"))
    {
      mysql_query(UPDATE users SET dp = dp - 0.005 WHERE id IN (SELECT author FROM posts WHERE id IN ($ids)));
      echo '<p>Post(s) successfully deleted. <a href="index.php">Back to forum</a>.</p>';
    }
    break;
    default:
    echo '<p>You have not selected an action. <a href="index.php">Click Here</a> to go to the forum index</p>';
  }
  }
  else
  {
    echo '<p>You have chosen invalid IDs. Please choose new ones <a href="index.php">here</a>.';
  }
}
else
{
  echo '<p>You need to be logged in as an administrator or moderator to do this.</p><p><a href="login.php">Click Here</a> to log in.';
}

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.