title: MYSQL need help pulling data from each "user" using php
body: <p>Here's what I have. This code grabs the data from all of the users and subtracts 1 from user_days then updates every user's user_days row.</p>
  
  <pre><code>$result = mysqli_query($con,"SELECT * FROM users");
  
  while($row = mysqli_fetch_array($result))
    {
    $minusone = $row['user_days']-1;
    mysqli_query($con,"UPDATE users SET user_days=$minusone");
    echo "&lt;br /&gt;";
    echo $row['user_days'];
    }
  </code></pre>
  
  <p>The problem I'm having is this:
  Instead of subtracting 1 from each user and updating each users field,
  it's updating each user's field with the value from the first user.</p>
  
  <p>example:
  before updating
  user 1 has 30 days
  user 2 has 60 days</p>
  
  <p>after updating
  user 1 has 29 days
  user 2 has 29 days (instead of 59 days)</p>
  
  <p>Any help is appreciated and I hope this question is easy to understand.</p>
  
  <p>Just to clarify, I DO want to update every field.
  I just don't want the updates to be duplicated from the first result.</p>
  
  <p>Thanks for all of the answers, this has given me a lot of help.</p>