title: Form input type php
body: <p>I want to create a form using a table where a column generates the questions( nom ) and another one generates the type of the response(type ) that can be  (text, date, checkbox, radio etc ...), I was able to generate the questions however I wasn't able to determinate the type.
  I am really struggling to use the type column in my champs table as a variable of input types in a form.<a href="https://i.stack.imgur.com/4bD7Y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4bD7Y.png" alt="enter image description here"></a></p>
  
  <p>Any help would be extremely appreciated</p>
  
  <p>to clarify more here are my codes:</p>
  
  <p><strong>ChampsModel.php</strong></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 
  require_once("../config/database.php");
  
  function Champsbyqid($qid){
   $c = Database :: connect();
   $results = array();
   $q = $c -&gt; prepare ("SELECT nom FROM champs WHERE qid=?") ;
   $q -&gt; execute (array($qid));
   while ($data = $q -&gt; fetch()) {
    $results[] = $data;
   } 
   Database :: disconnect();
   return $results;
  }
  
  function getType($qid){
   $c = Database :: connect();
   $results = array();
   $q = $c -&gt; prepare ("SELECT type FROM champs WHERE qid=?") ;
   $q -&gt; execute (array($qid));
   while ($data = $q -&gt; fetch()) {
    $results[] = $data;
   } 
   Database :: disconnect();
   return $results;
  }
  
  
  ?&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p><strong>ChampsController.php</strong></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 
  require_once("../model/champsModel.php");
  
  $champs = Champsbyqid(1);
  $type = getType(1);
  
  ?&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p><strong>Champs.php</strong> </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
  require_once("../controller/champsController.php");
  
  foreach ($champs as $value) {
   foreach ($types as $val) {
    echo $value['nom'].'&lt;form method="POST"&gt;&lt;input type='$val['type']'&gt;&lt;/form&gt;';
   }
   
  }
  
  
  ?&gt;  
  
  ?&gt;  </code></pre>
  </div>
  </div>
  </p>