title: QUERY AND ECHO Data INTO HTML INPUT fields
body: <p>I've written a script that in short is supposed to query data from the database and echo a result into a HTML form field. However, I have been unsuccessful. Please see code below:</p>
  
  <pre><code>&lt;?php
  
  
  include("dbconfig.php");
  
  $val = '6';
  
  $result = mysqli_query("Select * from test where testid= '$val'");
  $name = (mysqli_num_rows($result)==1) ? mysqli_fetch_assoc($result) : null;
  
  if(is_array($name)){
  
  
  ?&gt;
  
  &lt;html&gt;
  
  &lt;body&gt;
  
  &lt;form&gt;
  Name: &lt;input type="text" id="firstname" value="&lt;?php echo $name['firstname']; ?&gt;"/&gt;
  &lt;/form&gt;
  
  &lt;?php
  } else {
  
  echo "No such name exists";
  
  
  }
  
  ?&gt;
  
  
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Can someone please tell me what I'm doing wrong. Because it won't echo anything into the field and I find it rather annoying because majority of the scripts I've come across are quite similar to this one.</p>
  
  <p>Help will be much appreciated.</p>
  
  <p>Thank You,</p>
  
  <p>Sohail.</p>