title: Convert to PDO type mysql_fetch_array
body: <p>I would like to ask for assistance on how to convert the code below to PDO type especially the mysql_fetch_array. I can make it work properly using this code but I want to convert to PDO.</p>
  
  <pre><code> &lt;?php
  
      $query = "SELECT * from name";
      $result = mysql_query($query);
  
      $cols = 6;
      echo "&lt;table&gt;";
      do {
          echo "&lt;tr&gt;";
          for ($i = 1; $i &lt;= $cols; $i++) {
  
              $row = mysql_fetch_array($result);
              if ($row) {
                  $name = $row['fname'];
      ?&gt;
                      &lt;td&gt;
                      &lt;table&gt;
                      &lt;tr valign="top"&gt;
                      &lt;td&gt;
                      &lt;?php echo '&lt;input type="checkbox" name="name[]" id="name[]" value="' . $name . '"/&gt;' . $name . "\n"; ?&gt;
                      &lt;/td&gt;
                      &lt;td width="30"&gt;&amp;nbsp;&lt;/td&gt;   
                      &lt;/tr&gt;
                      &lt;/table&gt;
                      &lt;/td&gt;
      &lt;?php
              } else {
                  echo "&lt;td&gt;&amp;nbsp;&lt;/td&gt;";
              }
          }
      } while ($row);
      echo "&lt;/table&gt;";
      ?&gt;
  </code></pre>