Ich habe diesen Code, um alle Daten aus der DatenbankPHP-Schleife Array JavaScript-Array
while($row = mysqli_fetch_array($query)){
$therow1 = $row['r1'];
$therow2 = $row['r2'];
$therow3 = $row['r3'];//get
$therow4 = $row['r4'];//get
}
holen Wie kann ich die $therow3
und $therow3
als Array erhalten dann als Array auf Javascript passieren.
Die erwartete Ausgabe in JavaScript-Array wäre: $ the_array
[
[-33.890542, 151.274856],
[-33.923036, 151.259052],
[-34.028249, 151.157507],
[-33.80010128657071, 151.28747820854187],
[-33.950198, 151.259302]
];
Dann werde ich dieses Array verwenden in Javascript
<script type="text/javascript">
var locations = $the_array;
</script>
$ the_array [$ therow3] = $ row [ 'r3']; –
http://php.net/manual/en/language.types.array.php – Andreas
Mögliche Duplikate von [Wie übergeben Sie Variablen und Daten von PHP zu JavaScript?] (Http://stackoverflow.com/questions/23740548/) How-to-Pass-Variablen-und-Daten-von-PHP-zu-Javascript) – aghidini