I\'m looking for the best way to pass php array to javascript.
I\'m making a RPG, and when they login, I\'d like to return their saved data from database and store in an
What you need to do is, change this code:
while ($row = $result->fetch_assoc()) {
$message = $row['experience'] . $row['levelname'];
}
To make it as an array:
while ($row = $result->fetch_assoc()) {
$message[] = $row['experience'] . $row['levelname'];
}
So, $message
now becomes an array. You need to output this to the client. You can do that using:
die(json_encode($message));
The reason is, in your code, it will output only the last one.