title: Create Autofill form with PHP
body: <p>So im still relatively new to php and im trying to create a form that autofill's with information from a table. The table is called students and has the students id, first and last name, and their address. Im trying to make it so it only autofill's with the information of the student with a certain id, for example if the students id is 102 it fills the textboxes with their info.</p>
  <p>I have some code which i thought would work but its telling me somethings wrong with the while loop and i don't know what.</p>
  <p>Edit: The error i keep getting is this:&quot;mysqli_fetch_assoc() expects parameter 1 to be mysqli_result&quot;.</p>
  <p>PHP code:</p>
  <pre><code>&lt;?php
          
  require_once ('Connection.php');
  
  $query = &quot;SELECT * from students where Id = 102&quot;;
  
  $result = mysqli_query($dbc, $query);
  
  while ($row = mysqli_fetch_assoc($result)) {
   $row['student_id'];
   $row['stu_Fname'];
   $row['stu_Lname'];
   $row['stu_addr'];
  
  }               
  ?&gt;
  </code></pre>
  <p>Html Form:</p>
  <pre><code>&lt;form action=&quot;http://localhost/test.php&quot; method=&quot;post&quot;&gt;
          
          &lt;p&gt;Student ID:
              &lt;input name=&quot;stu_id&quot; size=&quot;5&quot; value=&quot;&lt;?php echo $row['student_id']; ?&gt;&quot; pattern=&quot;^\d{3}&quot; required autofocus /&gt;&lt;?php echo $row['student_id']; ?&gt;
          &lt;/p&gt;
          
          &lt;p&gt;First Name:
              &lt;input type=&quot;text&quot; name=&quot;fname&quot; size=&quot;30&quot; value=&quot;&lt;?php echo $row['stu_Fname']; ?&gt;&quot;/&gt;
          &lt;/p&gt; 
              
          &lt;p&gt;Last Name:
              &lt;input type=&quot;text&quot; name=&quot;lname&quot; size=&quot;30&quot; value=&quot;&lt;?php echo $row['stu_Lname']; ?&gt;&quot;/&gt;
          &lt;/p&gt;
          
          &lt;p&gt;Address:
              &lt;input type=&quot;text&quot; name=&quot;address&quot; size=&quot;30&quot; value=&quot;&lt;?php echo $row['stu_addr']; ?&gt;&quot;/&gt;
          &lt;/p&gt;
          
          &lt;p&gt;
              &lt;input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Send&quot;/&gt;
          &lt;/p&gt;
      &lt;/form&gt;
  </code></pre>
  <p>EDIT: Connection code:</p>
  <pre><code>&lt;?php
          
          DEFINE ('DB_User', 'testuser');
          DEFINE ('DB_Password', 'abc123*');
          DEFINE ('DB_Host', 'localhost');
          DEFINE ('DB_Name', 'student');          
          
          //start database connection
          $dbc = new mysqli(DB_Host, DB_User,DB_Password,DB_Name);
              
              if(mysqli_connect_errno())
              {
                  printf(&quot;can't connect to database.&quot;, mysqli_connect_error());
                  exit();
              }           
      ?&gt;
  </code></pre>