title: Display only First Fetched field in html form
body: <p><strong>Display value only in first field of form all the other fields showed blank even if those fields have values</strong></p>
  
  <p>I have fetched a number of fields from mySql query but it displays only the first fetched field and if i copy the name of the first fetched field as value of all the input boxes of form it only displays the first one other are blank.
  Other columns shows the Values when i echo those columns.</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
  &lt;title&gt;Library Information&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;?php
  //include 'Header.php';
  include 'AHome.php';
  require_once("connect.inc.php");
      $conn = mysqli_connect(HOST, DBUSER, PASS,DB) or    die('Could not connect !&lt;br /&gt;Please contact the site\'s administrator.');
  $result = mysqli_query($conn,"SELECT NM , ADDRESS1 , ADDRESS2 , CITY , STATE , COUNTRY , PHONENO , FAXNO , EMAIL1 FROM library_info LIMIT 1 ");
  if($result)
  {
      while($row = mysqli_fetch_array($result)) 
    { 
      $Nm1 = $row['NM'];
      $Add1 = $row['ADDRESS1'];
      $Add2 = $row['ADDRESS2'];
      $City = $row['CITY'];
      $State = $row['STATE'];
      $Country = $row['COUNTRY'];
      $Phone = $row['PHONENO'];
      $Fax = $row['FAXNO'];
      $Email1 = $row['EMAIL1'];
      echo $Add1;
      echo "&lt;form name='Lib-Info' id='Lib-Info' method='post' onsubmit='return validate()' action='LibInfo.php' &gt;
      &lt;fieldset&gt;
      &lt;legend&gt;
      Basic Information
      &lt;/legend&gt;
      &lt;dl&gt;
      &lt;dt&gt;
      Name: &lt;input tabindex='1' accesskey='n' name='Nm' type='text' maxlength='200' id='Nm' value = \"$Nm1\" /&gt;
      &lt;/dt&gt;
      &lt;/dl&gt;";
      echo "&lt;dl&gt;&lt;dt&gt;
      Address Line 1 &lt;input tabindex='2' accesskey='A' Name='Add1' type='text' maxlength='200' id='Add1' \"$Nm1\" /&gt;
      &lt;/dt&gt;&lt;/dl&gt;";
  echo    "&lt;dl&gt;&lt;dt&gt;
      Address Line 2 &lt;input tabindex='3' accesskey='B' Name='Add2' type='text' maxlength='200' id='Add2' \"$Nm1\" /&gt;
      &lt;/dt&gt;&lt;/dl&gt;
      &lt;dl&gt;&lt;dt&gt;
      City: &lt;input tabindex='4' accesskey='C' Name='City' type='text' maxlength='50' id='City' \"$Nm1\" /&gt;
      &lt;/dt&gt;&lt;/dl&gt;
      &lt;dl&gt;&lt;dt&gt;
      State &lt;input tabindex='4' accesskey='S' Name='State' type='text' maxlength='200' id='State' \"$Nm1\" /&gt;
      &lt;/dt&gt;&lt;/dl&gt;
      &lt;dl&gt;&lt;dt&gt;
      Country: &lt;input tabindex='5' accesskey='B' Name='Country' type='text' maxlength='200' id='Country' \"$Nm1\" /&gt;
      &lt;/dt&gt;&lt;/dl&gt;
      &lt;/fieldset&gt;
      &lt;fieldset&gt;
      &lt;legend&gt;Contact Details&lt;/legend&gt;
      &lt;dl&gt;&lt;dt&gt;
      Contact No: &lt;input tabindex='6' accesskey='P' Name='Phone' type='text' maxlength='200' id='Phone' \"$Nm1\" /&gt;
      &lt;/dt&gt;&lt;/dl&gt;
      &lt;dl&gt;&lt;dt&gt;
      Fax No.: &lt;input tabindex='7' accesskey='F' Name='Fax' type='text' maxlength='200' id='Fax' \"$Nm1\" /&gt;
      &lt;/dt&gt;&lt;/dl&gt;
      &lt;dl&gt;&lt;dt&gt;
      E-Mail: &lt;input tabindex='8' accesskey='E' Name='Email' type='text' maxlength='200' id='Email' \"$Nm1\" /&gt;
      &lt;/dt&gt;&lt;/dl&gt;
      &lt;/fieldset&gt;
      &lt;label title='Submit'&gt;
            &lt;input tabindex='9' accesskey='l' type='submit' name='Submit' value='Submit' /&gt;
            &lt;/label&gt;
      &lt;/form&gt;";
    }
  }
  else
  {
      die(mysqli_error($con));
  }
   include 'footer.php';?&gt;
  &lt;/body&gt;
  &lt;script&gt;
  function validate()
  {
      var Nm = document.getElementById("Nm")
      if(Nm.value=='')
      {
          alert("Library Name required");
  
          return(false);
      }
      Nm = '';
      Nm = document.getElementById("Add1");
      if(Nm.value=='')
      {
          alert("Address Line 1 required");
          return(false);
      }
      Nm = '';
      Nm = document.getElementById("Phone");
      if(Nm.value=='')
      {
          alert("Contact No. required");
          return(false);
      }
      Nm = '';
      Nm = document.getElementById("Email");
      if(Nm.value=='')
      {
          alert("Mail address required");
          return(false);
      }
  
      Nm = document.getElementById("");
      if(Nm.value=='')
      {
          alert("Library Name Required");
          return(false);
      }
  }
  &lt;/script&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Result</p>
  
  <p><a href="https://i.stack.imgur.com/5leth.png" rel="nofollow noreferrer">Output of Code</a></p>