Answers for "php select from database into array"

PHP
0

convert query result to array php

$result = "select * from random_table where id = 1";

$rows = [];
while($row = mysqli_fetch_array($result))
{
    $rows[] = $row;
}
Posted by: Guest on May-06-2021
0

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
Posted by: Guest on October-11-2021

Code answers related to "php select from database into array"

Browse Popular Code Answers by Language