how can I send multiple data from mysql to a php array and echo the first two entries? In my database I have the columns name, xkoord, ykoord. I have tried with json, but I guess this doesn't work. What I have is the following:
function load_db($var, $xkoord, $ykoord){
global $db;
$result = mysqli_query($db,"SELECT $var FROM armydb WHERE xkoord = '$xkoord' AND ykoord = '$ykoord'") OR DIE ('Fehler!');
$json = mysqli_fetch_all ($result, MYSQLI_ASSOC);
echo json_encode($json );
}
I call this function this way:
<?php
$name_array = json_decode(load_db('name', 1, 0), true);
echo $name_array[0];
echo $name_array[1];
?>
This doesnt work. Any Suggestion?