John Davidson

how to make a mysql query and turn it into an array in php


if I have a query that looks like this in php...

if ($result3 = $connuser->query("SELECT * FROM devices WHERE uid='".$username."'")){


How can I turn $result3 into an array?
Also, separate question, I tried doing

echo $result3;

but it doesn't work. Is there a way to view $result3 so I can see what it looks like?

My Answer:
>query("SELECT * FROM users")) {
$users = array();
while ($row = $result3->fetch_assoc()) {
$users[] = $row;

This code will execute the query and store the results in an array called $users. Each row from the query result will be added as an element in the array.

Rate this post

3 of 5 based on 2882 votes


© 2024 - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us