0

I'm trying to execute a simple MYSQL query in PHP but for some reasons it doesn't work. I am trying to update multiple rows in my "notifications" table based on "notification_seen" row and "notification_id" row.

This is my notifications table:

    |user_id |notification_id|notification_seen|
    |________|_______________|_________________|
    |   1    | 1             |0                |
    |   1    | 2             |0                |
    |   1    | 3             |0                |
    |________|_______________|_________________|

What i have so far in PHP:

$uid = '1';
$not_id = '1,2,3';
$stmt = $this->conn->prepare("
UPDATE notifications 
   SET notification_seen = 1 
 WHERE user_id = :uid 
   AND notification_id IN (:not_id)
");
$stmt->execute(array(':uid'=>$uid, ':not_id' => $not_id));

For some reasons the above query only updates the last row in my table. Thank you very much.

Filnor
  • 1,290
  • 2
  • 23
  • 28
Mojo Allmighty
  • 793
  • 7
  • 18

0 Answers0