php - Set Select query results as array -


i have query returns array, how output array thomas, james. want store in format within variable can call later. foreach? thanks

$stmt = $conn->prepare("select admin_name adminuser_tbl"); if ($stmt->execute()) {     while ($row = $stmt->fetch()) {          print_r($row);     } } 

this outputs:

array ( [admin_name] => thomas [0] => thomas ) array ( [admin_name] => james [0] => james )  

instead of

print_r($row); 

how about...

$name = join(", ", $row); 

or concatenate results array of names

$stmt = $conn->prepare("select admin_name adminuser_tbl"); $names = array(); if ($stmt->execute()) {     while ($row = $stmt->fetch()) {         $names[] = join(", ", $row);     } } 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -