convert query result to array php
$result = "select * from random_table where id = 1";
$rows = [];
while($row = mysqli_fetch_array($result))
{
$rows[] = $row;
}
convert query result to array php
$result = "select * from random_table where id = 1";
$rows = [];
while($row = mysqli_fetch_array($result))
{
$rows[] = $row;
}
php select from database into array
<?php
// run query
$query = mysql_query("SELECT * FROM table");
// set array
$array = array();
// look through query
while($row = mysql_fetch_assoc($query)){
// add each row returned into an array
$array[] = $row;
// OR just echo the data:
echo $row['username']; // etc
}
// debug:
print_r($array); // show all array data
echo $array[0]['username']; // print the first rows username
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us