mysql - fetch value into td tag with php and pdo -
with code inside td-tag text "array" showing up. how can real value?
<tbody> <tr> <?php $sth = $dbh->prepare("select * customers"); $sth->execute(); $result = $sth->fetchall(); foreach($result $key => $value) { echo "<td>$value</td>"; } ?> </tr> </tbody>
foreach($result $key => $value) { echo "<td>{$value['field_name']}</td>"; }
here $value
array because $result
should 2 dimensional array. need call this.
echo "<td>{$value['field_name']}</td>";
you can add foreach
.
foreach($result $key => $inner_arr) { echo '<tr>'; foreach($inner_arr $field_name => $field_value) { echo "<td>{$field_value}</td>"; } echo '</tr>'; }
Comments
Post a Comment