1

when I attempt to echo these names, nothing comes up...

//  
$getuser = "SELECT * FROM user WHERE account_id = $id";     
$showuser = @mysqli_query ($dbc, $getuser); // Run the query.

while ($row = mysqli_fetch_array($showuser, MYSQLI_ASSOC)) {

 $names[]=$row['user_username'];

 }


echo $names;

4 Answers 4

4

To Echo an Array use

print_r($names)

Echo will only print out a simple variable (Text, Number). print_r is used to format and print out complex types such as arrays and objects.

Further information can be found on the php.net website.

http://php.net/manual/en/function.print-r.php

Sign up to request clarification or add additional context in comments.

Comments

2

You can use print_r() or var_dump()

Comments

1

Instead of echo use print_r.

print_r($names); 

Like that.

Comments

-1

you should initialize $names as array before the while loop $names = array();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.