'How to update multiple ids in wordpress php and mysql(I am trying to update quetion and answer in quiz app)

I am tryting update answers with different quetion ids but only one first id will be updated so how to fix , please help...thank you in advance

  $sql = "SELECT * FROM $table WHERE id='$updated_id'" ;
    $user = $wpdb->get_var($sql);  
           
    if ($user){       
        if (isset($_POST['question_id'])) {           
        $updated = $wpdb->update( $table, ['quetion' =>$quetion], ['id' => $updated_id ] );         
        global $wpdb;
        $update_quetionids = $wpdb->get_col("SELECT id FROM wp_quetion_answer WHERE quetion_id = $updated_id");
        print_r($update_quetionids);    
     foreach($update_quetionids as $key => $value1){
      foreach($answers as $key=>$value){
         if($correct_answer == $value){
               $is_correct = 1;
            }
         else{
            $is_correct = 0;
            }
            
       $data = array('is_correct' => $is_correct,
      'answers'=>$value,   
       );  
    }
       print_r($data);
     $where = array('id' => $value1);}
     $wpdb->update(
        'wp_quetion_answer',
         $data,
         $where,
        );
 }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source