Skip to content
Advertisement

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?

Advertisement

Answer

You can do:

$rows = [];
while($row = mysqli_fetch_array($result3))
{
    $rows[] = $row;
}
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement