0

I have some array like this
When I use code like this :

I got this error : Notice: Undefined index: users_id in D:\xampp\htdocs\home\database\index.php on line 21

I want to call specific columns like : users_id , users_username ,etc.

If I use :

var_dump ($rowset);

I got :

Array ( [0] => Array ( [users_id] => 1 [users_username] => admin [users_password] => admin

My Code :

$rowset = array();
    while ($row = $sql->fetch(PDO::FETCH_ASSOC)){  `enter code here`
        $rowset[] = $row;
    }
        echo $rowset["users_id"];// Line 21

Thanks

2

2 Answers 2

1

Once try like this,

foreach($rowset as $k => $v){
 echo $rowset[$k]["users_id"];
}
Sign up to request clarification or add additional context in comments.

3 Comments

Then i got just one users_id
then use foreach, check answer again
:D This message is for you, :p DO it after six minutes.
0

you may make use of the pretty array_column :

$user_ids = array_column($rowset, 'users_id');

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.