title: Load MySQL data into texboxes on button click
body: <p>I have a webpage that needs to load data from a MySQL db into textboxes. So, the textboxes already exist and the values needs to be updated with those from the db. I have a JavaScript function for the button click, a PHP script to connect the db, but it doesn't seems to work. It just copies  in the textboxes, but the value stored in the db.
  Any idea what I do wrong?</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
     &lt;title&gt;&lt;/title&gt;
     &lt;style type="text/css"&gt;
          ...
     &lt;/style&gt;
     &lt;script&gt;
     //LOAD DATA      
          function btn_load_Click(){
                  document.getElementById('item1').value ="&lt;?php echo $row['item1'];?&gt;" ;
                  document.getElementById('item2').value ="&lt;?php echo $row['item2'];?&gt;" ;
                  document.getElementById('item3').value ="&lt;?php echo $row['item3'];?&gt;" ;
                  document.getElementById('item4').value ="&lt;?php echo $row['item4'];?&gt;" ;
          }
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;?php
  $servername = "something.com.mysql";
  $username = "myName";
  $password = "xxxx";
  $dbname = "myDB"
  
  $conn = mysqli_connect($servername, $username, $password, $dbname);
  if (!$conn){
  die("Connection failed:".mysqli_connect_error());
  }
  else {
  $sql = "SELECT item1, item2, item3, item4 FROM myTable";
  $result = mysqli_query($conn, $sql);
  $row = mysql_fetch_array($result);
  
  }
  mysqli_close($conn);
  ?&gt;
  &lt;form id="form1" style="width:500px;" method="post"&gt;
      &lt;div&gt;&lt;button type="button" id="btn_load" onClick="btn_load_Click();" &gt;&lt;/button&gt;&lt;/div&gt;
  &lt;div id="MyItems"&gt;
      &lt;div&gt;&lt;input id="item1" type="text" value=""/&gt;&lt;/div&gt;
      &lt;div&gt;&lt;input id="item2" type="text" value=""/&gt;&lt;/div&gt;
      &lt;div&gt;&lt;input id="item3" type="text" value=""/&gt;&lt;/div&gt;
      &lt;div&gt;&lt;input id="item4" type="text" value=""/&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>