I want to output all records in my database. So far so good, but when I loop through it, php gives me an error " Array to string conversion ".
-
I added an index to the array but then it does just output obviously the first or secound ( etc. ) column.
$conn = new PDO("mysql:host=localhost;dbname=database","root",""); $stmt = $conn->prepare('SELECT * FROM de'); $stmt ->execute(); $result = $stmt ->fetchAll(); if (is_array($result) || is_object($result)) { foreach ($result[0] as $value) { echo "<table><tr><td>'$value'</td></tr></table>"; } }
So, with the index, it does work. But I need all records, not just one.
I appreciate every comment and help!