php - How to output query data -


i've been trying day, looked @ references, looked @ other questions similar mine, nothing seems working.

problem: can't output query data.

this recent iteration of code:

try {     $link = new pdo('mysql:host=localhost;dbname=users_db', 'root', '56235623'); } catch (pdoexception $e) {     print "error!: " . $e->getmessage() . "<br/>";     die(); } $sql = $link->prepare('select * users'); $sql->execute();  $result = $sql->fetchall(pdo::fetch_assoc);  foreach ($result $key=>$value){     echo $key.$value; } 

here output:

notice: array string conversion in c:\xampp\htdocs\myproject\includes\cn.php on line 23 0array notice: array string conversion in c:\xampp\htdocs\myproject\includes\cn.php on line 23 1array notice: array string conversion in c:\xampp\htdocs\myproject\includes\cn.php on line 23 2array notice: array string conversion in c:\xampp\htdocs\myproject\includes\cn.php on line 23 3array

fetchall returns 2-dimensional array. first dimension rows, second dimension columns. need nested loops:

foreach ($result $i => $row) {     echo "row: $i\n";     foreach ($row $key => $value) {         echo "$key: $value; ";     } } 

Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -