i'm trying to create an array with PHP and MySQL, but i always get errors.
The code i'm using
function db_listar_usuarios(){
$link=db_connect();
$query = "select * from usuarios" or die("Problemas en el select: " . mysqli_error($link));
$result = $link->query($query);
while($row = mysqli_fetch_assoc($result)) {
echo $row['nombre'] . array(;
foreach ($row as $col => $val) {
$col => $val;
}
echo "
############
";
}
}
And what I want to create with this code is:
array(
'john' => array('address' => 'st 123', 'age' => '25', 'surname' => 'doe'),
'ane' => array('address' => 'av 456', 'age'=> '32', 'surname' => 'smith'),
);
To use then like something like this:
private $contacts = db_listar_usuarios();
Thank you in advance :)