php - PDO query - loop produces duplicate fields? -


the code below producing duplicate <td> elements each field. trying produce simple html table based on results of pdo query. can tell me why each field being duplicated?

$data = $conn->query('select * students');  // print results in html table echo '<table border="1" cellpadding="5">'; foreach($data $row) {   echo '<tr>';   foreach ($row $field) {     echo '<td>' . $field . '</td>';   }   echo '</tr>'; } echo '</table>'; 

thanks

it looks using pdo::fetch_both style.

this produce array entries duplicated, once column name keys, , once integer keys.

see following details:

http://php.net/manual/en/pdostatement.fetch.php


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -