title: Insert only stores the first digit, remainder are ignored
body: <p>I have a question regarding my database. I have develop a system where it will calculate the percentage automatically when user insert the values. My problem right now is, my database only stored the first digit. For example, if I enter 4000, it will only store 4,and at first I thought maybe there was something going on with the 3 zeroes behind but that was not it, and if I insert 3245, it still only store 3. </p>
  
  <p>Below is my database;
  <a href="https://i.stack.imgur.com/esFdj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/esFdj.png" alt="enter image description here"></a></p>
  
  <p>and here the codes related to this database.</p>
  
  <p>add records:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;form action="" method="post"&gt;
  
  &lt;div&gt;
  
  &lt;?php if ($id != '') { ?&gt;
  
  &lt;input type="hidden" name="id" value="&lt;?php echo $id; ?&gt;" /&gt;
  
  &lt;p&gt;ID: &lt;?php echo $id; ?&gt;&lt;/p&gt;
  
  &lt;?php } ?&gt;
  
  
  
  
  
  &lt;p&gt;&lt;strong&gt;Tarikh&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;: *&lt;/strong&gt;
  
  &lt;input type="text"  style="text-transform:uppercase" name="date" value=" &lt;?php echo $date; ?&gt;"/&gt;&lt;br/&gt;&lt;/p&gt;
  
  &lt;p&gt;&lt;strong&gt;Di bawah 60 Minit  : *&lt;/strong&gt; &lt;input type="text" name="casesolved_u"
  
  value="&lt;?php echo $casesolved_u; ?&gt;"/&gt;&lt;br/&gt;&lt;/p&gt;
  
  &lt;p&gt;&lt;strong&gt;Jumlah kes &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;: *&lt;/strong&gt; &lt;input type="text" name="casesolved_a"
  
  value="&lt;?php echo $casesolved_a; ?&gt;"/&gt;&lt;/p&gt;
  
  
  
  &lt;!--Remove Percentage entry --&gt;
  
  
  &lt;p&gt;* required&lt;/p&gt;
  
  &lt;input type="submit" name="submit" value="Submit" /&gt;
  
  &lt;/div&gt;
  
  &lt;/form&gt;&lt;/center&gt;
  
  
  
  &lt;/body&gt;
  
  &lt;/html&gt;
  
  
  
  &lt;?php }
  
  
  
  /*
  
  EDIT RECORD
  
  */
  
  // if the 'id' variable is set in the URL, we know that we need to edit a record
  
  if (isset($_GET['id']))
  
  {
  
  // if the form's submit button is clicked, we need to process the form
  
  if (isset($_POST['submit']))
  
  {
  
  // make sure the 'id' in the URL is valid
  
  if (is_numeric($_POST['id']))
  
  {
  
  // get variables from the URL/form
  
  $id = $_POST['id'];
  
  $date = strtoupper($_POST['date']);
  
  $casesolved_u = htmlentities($_POST['casesolved_u'], ENT_QUOTES);
  
  $casesolved_a = htmlentities($_POST['casesolved_a'], ENT_QUOTES);
  
  
  
  //check if empty
  
  if ($date == '' || $casesolved_u == ''||$casesolved_a =='')
  
  {
  
  // if they are empty, show an error message and display the form
  
  $error = 'ERROR: Please fill in all required fields!';
  
  renderForm($date, $casesolved_u, $casesolved_a, $percentage ,$error, $id);
  
  }
  
  else
  
  {
  
   $percentage = ($casesolved_u * 100 / $casesolved_a);
  
   //apply the proper formatting
  
  $casesolved_u = number_format ($casesolved_u, 2);
  $casesolved_a = number_format ($casesolved_a, 2);
  $percentage = number_format ($percentage,2);
   
  
  
  // if everything is fine, update the record in the database
  
  if ($stmt = $mysqli-&gt;prepare("UPDATE ae SET date = ?, casesolved_u = ?, casesolved_a=?, percentage=?
  
  WHERE id=?"))
  
  {
  
  $stmt-&gt;bind_param("ssssi", $date, $casesolved_u, $casesolved_a, $percentage ,$id);
  
  $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 'id' variable is not valid, 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 'id' value is valid
  
  if (is_numeric($_GET['id']) &amp;&amp; $_GET['id'] &gt; 0)
  
  {
  
  // get 'id' from URL
  
  $id = $_GET['id'];
  
  
  
  // get the recod from the database
  
  if($stmt = $mysqli-&gt;prepare("SELECT id, date, casesolved_u, casesolved_a, percentage FROM ae WHERE id =?"))
  
  
  
  {
  
  $stmt-&gt;bind_param("i", $id);
  
  $stmt-&gt;execute();
  
  
  
  $stmt-&gt;bind_result($id, $date, $casesolved_u, $casesolved_a, $percentage);
  
  $stmt-&gt;fetch();
  
  
  
  // show the form
  
  renderForm($date, $casesolved_u, $casesolved_a , $percentage, NULL, $id);
  
  
  
  $stmt-&gt;close();
  
  }
  
  // show an error if the query has an error
  
  else
  
  {
  
  echo "Error: could not prepare SQL statement"; 
  
  }
  
  }
  
  // if the 'id' value is not valid, redirect the user back to the view.php page
  
  else
  
  {
  
  header("Location: view.php");
  
  }
  
  }
  
  }
  
  
  
  
  /*
  
  NEW RECORD
  
  */
  
  // if the 'id' variable is not set in the URL, we must be creating a new record
  
  else
  
  {
  
  // if the form's submit button is clicked, we need to process the form
  
  if (isset($_POST['submit']))
  
  {
  
  // get the form data
  
  $date = strtoupper($_POST['date']);
  
  $casesolved_u = htmlentities($_POST['casesolved_u'], ENT_QUOTES);
  
  $casesolved_a = htmlentities($_POST['casesolved_a'], ENT_QUOTES);
  
  
  
  // check that no empty value inserted
  
  if ($date == '' || $casesolved_u == '' ||$casesolved_a == '')
  
  {
  
  // if they are empty, show an error message and display the form
  
  $error = 'ERROR: Please fill in all required fields!';
  
  renderForm($date, $casesolved_u, $casesolved_a, $percentage, $error);
  
  }
  
  else
  
  {
  
  
   $percentage = ($casesolved_u * 100 / $casesolved_a);
  
   //apply the proper formatting
  
  $casesolved_u = number_format ($casesolved_u, 2);
  $casesolved_a = number_format ($casesolved_a, 2);
  $percentage = number_format ($percentage,2);
  
  
  // insert the new record into the database
  
  if ($stmt= $mysqli-&gt;prepare ("INSERT INTO ae (date, casesolved_u, casesolved_a, percentage) VALUES (?,?,?,?)"))
  
  {
  
  $stmt-&gt;bind_param("ssss",$date, $casesolved_u, $casesolved_a, $percentage);
  
  $stmt-&gt;execute();
  
  $stmt-&gt;close();
  
  }
  
  // show an error if the query has an error
  
  else
  
  {
  echo "ERROR: Could not prepare SQL statement.";
  
  }
  
  // redirec the user
  
  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>
  </div>
  </div>
  </p>
  
  <p>and here is the view code;</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php
  // connect to the database
  include('connect-db.php');
  
  // get the records from the database
  if ($result = $mysqli-&gt;query("SELECT * FROM ae ORDER BY id"))
  {
  // display records if there are records to display
  if ($result-&gt;num_rows &gt; 0)
  {
  // display records in a table
  echo "&lt;table border='1' cellpadding='10'&gt;";
  
  // set table headers
  echo "&lt;tr&gt;&lt;th&gt;&amp;nbsp Tarikh &amp;nbsp&lt;/th&gt;&lt;th&gt; &amp;nbsp Discaj Dalam Masa 2 Jam &amp;nbsp &lt;/th&gt;&lt;th&gt; &amp;nbsp Jumlah Kes &amp;nbsp &lt;/th&gt;&lt;th&gt;Peratusan&lt;/th&gt;&lt;th&gt;&amp;nbsp &amp;nbsp &amp;nbsp &amp;nbsp &amp;nbsp &amp;nbsp &amp;nbsp &amp;nbsp&lt;/th&gt;&lt;th&gt;&amp;nbsp &amp;nbsp &amp;nbsp &amp;nbsp &amp;nbsp &amp;nbsp &amp;nbsp &amp;nbsp&lt;/th&gt;&lt;/tr&gt;";
  
  while ($row = $result-&gt;fetch_object())
  {
  // set up a row for each record
  echo "&lt;tr&gt;";
  
  echo "&lt;td&gt;" . $row-&gt;date . "&lt;/td&gt;";
  echo "&lt;td&gt;" . $row-&gt;casesolved_u . "&lt;/td&gt;";
  echo "&lt;td&gt;" . $row-&gt;casesolved_a . "&lt;/td&gt;";
  echo "&lt;td&gt;" . $row-&gt;percentage . "&lt;/td&gt;";
  echo "&lt;td&gt;&lt;a href='records.php?id=" . $row-&gt;id . "'&gt;Edit&lt;/a&gt;&lt;/td&gt;";
  echo "&lt;td&gt;&lt;a href='delete.php?id=" . $row-&gt;id . "'&gt;Delete&lt;/a&gt;&lt;/td&gt;";
  echo "&lt;/tr&gt;";
  }
  
  echo "&lt;/table&gt;";
  }
  // if there are no records in the database, display an alert message
  else
  {
  echo "Tiada maklumat untuk dipamerkan";
  }
  }
  // show an error if there is an issue with the database query
  else
  {
  echo "Error: " . $mysqli-&gt;error;
  }
  
  // close database connection
  $mysqli-&gt;close();
  
  ?&gt;
  &lt;p&gt;
  &lt;/p&gt;
   &lt;center&gt;&lt;a href="records.php"&gt;  Tambah Rekod Baru&lt;/a&gt;&lt;/center&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Please, point me to where I do wrong that cause my database to only store the first digit into the database.</p>