title: when modifying one sql record it is modifying all the table
body: <p>I'm trying to edit only one record in the table via this php code .
  But the problem is if the same customer has multiple records in the table , then when I edit one record , the code is editing all the customer records to the one I've edited ..
  Let me explain further :
  This is the php code I'm using:</p>
  
  <pre><code>&lt;?php
  
  // server info
  $server = 'localhost';
  $user = 'root';
  $pass = '';
  $db = 'mysql';
  
  // connect to the database
  $mysqli = new mysqli($server, $user, $pass, $db);
  
  // show errors (remove this line if on a live site)
  mysqli_report(MYSQLI_REPORT_ERROR);
  
  function renderForm($customer_name = '', $MGMT_IP = '', $Vendor = '', $Version = '', $GUI_User = '', $GUI_Pass = '', $Notes = '', $error = '', $customer_number = '')
  { ?&gt;
  
  &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt;
  &lt;html&gt;
  &lt;html dir="rtl" lang="ar"&gt;
  &lt;head&gt;
  &lt;title&gt;
  &lt;?php if ($customer_number != '') { echo "edit customer record"; } else { echo "New Record"; } ?&gt;
  &lt;/title&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"/&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;h1&gt;&lt;?php if ($customer_number != '') { echo "type in the all required fields"; } else { echo "New Record"; } ?&gt;&lt;/h1&gt;
  &lt;?php if ($error != '') {
  echo "&lt;div style='padding:4px; border:1px solid red; color:red'&gt;" . $error
  . "&lt;/div&gt;";
  } ?&gt;
  
  &lt;form action="" method="post"&gt;
  &lt;div&gt;
  &lt;?php if ($customer_number != '') { ?&gt;
  &lt;input type="hidden" name="customer_number" value="&lt;?php echo $customer_number; ?&gt;" /&gt;
  &lt;p&gt;customer_number: &lt;?php echo $customer_number; ?&gt;&lt;/p&gt;
  &lt;?php } ?&gt;
  
  &lt;strong&gt;customer name: *&lt;/strong&gt; &lt;input type="text" name="customer_name"
  value="&lt;?php echo $customer_name; ?&gt;"/&gt;&lt;br/&gt;&lt;br/&gt;
  &lt;label for="Vendor"&gt;vendor&lt;/label&gt;
  &lt;select name="Vendor"&gt;
  &lt;option value="Juniper"&gt;Juniper&lt;/option&gt;
  &lt;option value="Fortinet"&gt;Fortinet&lt;/option&gt;
  &lt;option value="Websense"&gt;Websense&lt;/option&gt;
  &lt;option value="F5"&gt;F5&lt;/option&gt;
  &lt;option value="Cisco"&gt;Cisco&lt;/option&gt;
  &lt;option value="Backbox"&gt;Backbox&lt;/option&gt;
  &lt;option value="Radware"&gt;Radware&lt;/option&gt;
  &lt;option value="Orion"&gt;Orion&lt;/option&gt;
  &lt;option value="VM"&gt;VM&lt;/option&gt;
  &lt;option value="EMC"&gt;EMC&lt;/option&gt;
  &lt;option value="Backup"&gt;Backup&lt;/option&gt;
  &lt;option value="HP"&gt;HP&lt;/option&gt;
  &lt;option value="Storage"&gt;Storage&lt;/option&gt;
  &lt;option value="PinApp"&gt;PineApp&lt;/option&gt;
  &lt;option value="RDP"&gt;RDP&lt;/option&gt;
  &lt;/select&gt;&lt;br/&gt;&lt;br/&gt;
  
  &lt;strong&gt;MGMT IP: *&lt;/strong&gt; &lt;input type="text" name="MGMT_IP"
  value="&lt;?php echo $MGMT_IP; ?&gt;"/&gt;&lt;br/&gt;&lt;br/&gt;
  &lt;strong&gt;version: *&lt;/strong&gt; &lt;input type="text" name="Version"
  value="&lt;?php echo $Version; ?&gt;"/&gt;&lt;br/&gt;&lt;br/&gt;
  &lt;strong&gt;GUI User: *&lt;/strong&gt; &lt;input type="text" name="GUI_User"
  value="&lt;?php echo $GUI_User; ?&gt;"/&gt;&lt;br/&gt;&lt;br/&gt;
  &lt;strong&gt;GUI Pass: *&lt;/strong&gt; &lt;input type="text" name="GUI_Pass"
  value="&lt;?php echo $GUI_Pass; ?&gt;"/&gt;&lt;br/&gt;&lt;br/&gt;
  &lt;strong&gt;notes: &lt;/strong&gt; &lt;input type="text" name="Notes"
  value="&lt;?php echo $Notes; ?&gt;"/&gt;
  &lt;p&gt;* FILLUP REUIRED FIELDS&lt;/p&gt;
  &lt;input type="submit" name="submit" value="Submit" /&gt;
  &lt;/div&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  
  &lt;?php }
  
  /*
  
  EDIT RECORD
  
  */
  
  
  {
  // if the 'customer_number' variable is set in the URL, we know that we need to edit a record
  if (isset($_GET['customer_number']))
  {
  // if the form's submit button is clicked, we need to process the form
  if (isset($_POST['submit']))
  {
  // make sure the 'customer_number' in the URL is valid
  if (is_numeric($_POST['customer_number']))
  {
  // get variables from the URL/form
  $customer_number = $_POST['customer_number'];
  $customer_name = htmlentities($_POST['customer_name'], ENT_QUOTES);
  $Vendor = htmlentities($_POST['Vendor'], ENT_QUOTES);
  $MGMT_IP = htmlentities($_POST['MGMT_IP'], ENT_QUOTES);
  $Version = htmlentities($_POST['Version'], ENT_QUOTES);
  $GUI_User = htmlentities($_POST['GUI_User'], ENT_QUOTES);
  $GUI_Pass = htmlentities($_POST['GUI_Pass'], ENT_QUOTES);
  $Notes = htmlentities($_POST['Notes'], ENT_QUOTES);
  
  
  // check that customer_name and Vendor are both not empty
  if ($customer_name == '' || $Vendor == '' || $MGMT_IP == '' || $Version == '' || $GUI_User == '' || $GUI_Pass == '')
  {
  // if they are empty, show an error message and display the form
  $error = 'error: fill up required fields!';
  renderForm($customer_name, $Vendor, $MGMT_IP, $Version, $GUI_User, $GUI_Pass, $Notes, $error, $customer_number);
  }
  else
  {
  // if everything is fine, update the record in the database
  if ($stmt = $mysqli-&gt;prepare("UPDATE cloud_team SET customer_name = ?, Vendor = ?, MGMT_IP = ?, Version = ?, GUI_User = ?, GUI_Pass = ?, Notes = ?
  WHERE customer_number=?"))
  {
  $stmt-&gt;bind_param("sssssssi", $customer_name, $Vendor, $MGMT_IP, $Version, $GUI_User, $GUI_Pass, $Notes, $customer_number);
  $stmt-&gt;execute();
  $stmt-&gt;close();
  }
  // show an error message if the query has an error
  else
  {
  echo "ERROR: could not prepare SQL statement.";
  }
  
  // redirect the user once the form is updated
  header("Location: view.php");
  }
  }
  // if the 'customer_number' variable is not valid_number, show an error message
  else
  {
  echo "Error!";
  }
  }
  // if the form hasn't been submitted yet, get the info from the database and show the form
  else
  {
  // make sure the 'customer_number' value is valcustomer_number
  if (is_numeric($_GET['customer_number']) &amp;&amp; $_GET['customer_number'] &gt; 0)
  {
  // get 'customer_number' from URL
  $customer_number = $_GET['customer_number'];
  
  // get the recod from the database
  if($stmt = $mysqli-&gt;prepare("SELECT * FROM cloud_team WHERE customer_number=?"))
  {
  $stmt-&gt;bind_param("i", $customer_number);
  $stmt-&gt;execute();
  
  $stmt-&gt;bind_result($customer_number, $customer_name, $Vendor, $MGMT_IP, $Version, $GUI_User, $GUI_Pass, $Notes);
  $stmt-&gt;fetch();
  
  // show the form
  renderForm($customer_name, $Vendor, $MGMT_IP, $Version, $GUI_User, $GUI_Pass, $Notes, NULL, $customer_number);
  
  $stmt-&gt;close();
  }
  // show an error if the query has an error
  else
  {
  echo "Error: could not prepare SQL statement";
  }
  }
  // if the 'customer_number' value is not valid, redirect the user back to the joomla_31/index.php/juniper page
  else
  {
  header("Location: view.php");
  }
  }
  }
  // if the form hasn't been submitted yet, show the form
  else
  {
  renderForm();
  }
  }
  // close the mysqli connection
  
  $mysqli-&gt;close();
  ?&gt;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/X7EyW.png" rel="nofollow noreferrer">This is before editing the first row</a></p>
  
  <p><a href="https://i.stack.imgur.com/hItRM.png" rel="nofollow noreferrer">And this is after editing the first row</a></p>