MYSQL 2 JSON with PHP Saved as JSON-File
Mysql2Json.php
PHP File save into APACHE-Server
<?php header('Access-Control-Allow-Origin: *'); $host = "localhost"; $databasename = "kasse_sql"; $username ="root"; $x = $_GET['t']; $tmp = explode(";",$x); $password = $tmp[0]; $query = $tmp[1] ; $filename = $tmp[2]; $con = mysql_connect($host,$username,$password) or die(mysql_error()); // SOLUTION FOR UTF8 GERMAN-CHARACTERS ( ü Ü ß ä Ä .....) // Without this Parameter show the JqxGrid another Characters mysql_query('SET CHARACTER SET utf8'); mysql_select_db($databasename) or die(mysql_error()); $results = mysql_query($query); $records = array(); while($obj = mysql_fetch_object($results)) { $records []= $obj; } //echo json_encode($records); //file_put_contents("data.json", json_encode($records)); switch ($filename){ case 1: file_put_contents("Kellnerdaten.json", json_encode($records)); break; case 2: file_put_contents("ipadSpeisekarte.json", json_encode($records)); break; case 3: file_put_contents("ipadWarenGruppen.json", json_encode($records)); break; case 4: file_put_contents("ipadBelegung.json", json_encode($records)); break; default: echo "Filename was not 1-4"; break; } ?>
Call From NSB-APPStudio
.............. .............. .............. Rem dont forget ";" otherwiese php-file can'nt parse your command cmdMYSQL = "MY MYSQL_PASSWORT;" Rem MySql SELECT Command cmdMYSQL += "Select Kellner, Passwort from Kellner;" Rem Filename to Save (look in mysql2json.php ) cmdMYSQL += "1;" Rem Ajax CMD req=Ajax("http://localhost/Kasse/mysql2json.php?t=" & cmdMYSQL ) Rem RESULT If req.status=200 Then console.log(req.responseText) ................ ................ ................ ................ ................