title: Rows with the same primary key is updated simultaneously
body: <p>I have session where after user login, they can book through the form and can update. However, the rows with the foreign key (user_id) in table <strong>Tempahan</strong> is updated simultaneously.</p>
  <p><a href="https://i.stack.imgur.com/aNzso.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aNzso.png" alt="enter image description here" /></a></p>
  <p>for example, if I want to click update for No4, it was updated BUT other rows is also changed.</p>
  <p><strong>Table structure for table <code>user</code></strong> :
  PK: user_id</p>
  <pre><code>CREATE TABLE `user` (
    `user_id` varchar(100) NOT NULL,
    `user_name` varchar(200) NOT NULL,
    `user_email` varchar(200) NOT NULL,
    `user_password` varchar(50) NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  </code></pre>
  <p><strong>Table structure for table <code>tempahan</code></strong> : PK tempahan_id, FK user_id</p>
  <pre><code>CREATE TABLE `tempahan` (
    `tempahan_id` int(11) NOT NULL,
    `noPhone` varchar(20) NOT NULL,
    `alamat` varchar(500) NOT NULL,
    `daerah` varchar(100) NOT NULL,
    `negeri` varchar(100) NOT NULL,
    `poskod` varchar(10) NOT NULL,
    `tajuk` varchar(200) NOT NULL,
    `anjuran` varchar(300) NOT NULL,
    `tarikh` date NOT NULL,
    `masa` time NOT NULL,
    `aturcara` varchar(300) DEFAULT NULL,
    `created_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
    `user_id` varchar(100) NOT NULL
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  </code></pre>
  <p>below is the process of update. actually I use PDO but I removed it for awhile and use the mysqli statement.</p>
  <pre><code>&lt;?php
      
          include(&quot;conn.php&quot;);
      
         session_start();
      
              $user_id = $_SESSION[&quot;user_id&quot;];
      
              $noPhone = $_POST[&quot;noPhone&quot;];
              $alamat = $_POST[&quot;alamat&quot;];
              $daerah = $_POST[&quot;daerah&quot;];
              $negeri = $_POST[&quot;negeri&quot;];
              $poskod = $_POST[&quot;poskod&quot;];
              $tajuk = $_POST[&quot;tajuk&quot;];
              $anjuran = $_POST[&quot;anjuran&quot;];
              $tarikh = $_POST[&quot;tarikh&quot;];
              $masa = $_POST[&quot;masa&quot;];  
              
      
               $sql = &quot;UPDATE TEMPAHAN SET noPhone = '$noPhone', alamat = '$alamat', 
              daerah = '$daerah', negeri = '$negeri', poskod = '$poskod', tajuk = '$tajuk', anjuran = '$anjuran'
              , tarikh = '$tarikh', masa = '$masa' where user_id = '$user_id'&quot;;
      
              $query = mysqli_query($conn, $sql);
          
      
              if($query)
                  echo &quot;&lt;meta http-equiv=\&quot;refresh\&quot;content=\&quot;2;URL=senaraiTempahan.php\&quot; /&gt;&quot;;
              else
                  echo &quot;Update failed&quot;;   
          
          
          
      ?&gt;
  </code></pre>