Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Got it, thanks to you guys!</p> <pre><code>// Get a request from i.e. a webpage (this is a webservice) $jsonArray = file_get_contents('php://input'); // put the JSON-Data into an array $jsonData = json_decode($jsonArray, true); // You can simply choose the entry-points. As they do not change for me, they are hardcoded in here, else you had to use something like a for-loop to extract them $jsonConnect = $jsonData['connected']; $jsonLocation = $jsonData['location']; $jsonConfigured = $jsonData['configured']; // walk through the JSON-Data and extract the values, although the array has more than 2 levels, you can select your entry-point and walk from there on, which makes this quite easy for($i = 0; $i &lt; count($jsonConfigured); $i++){ // keyMgmnt itself is an array and I want to concatenate all of its values and put it into a single field in my MySQL-DB, so implode() is used $keyMgmnt = implode(",", $jsonConfigured[$i]['keyMgmnt']); $grCiphers = implode(",", $jsonConfigured[$i]['grCiphers']); $ssid = $jsonConfigured[$i]['ssid']; $bssid = $jsonConfigured[$i]['bssid']; // from here on I simply put the variables into my MySQL-DB $sql_configured = "INSERT INTO configured (keyMgmnt, grCiphers, ssid, bssid) VALUES ('$keyMgmnt', '$grCiphers', '$ssid', '$bssid')"; mysql_query($sql_configured) or die ("Failure in configured"); } $sql_connected = "INSERT INTO connected (rssi, speed, ssid, bssid) VALUES ('$jsonConnect[rssi]', '$jsonConnect[speed]', '$jsonConnect[ssid]', '$jsonConnect[bssid]')"; $enterConnected = mysql_query($sql_connected) or die("Failure in connection!"); $sql_location = "INSERT INTO location (lat, prov, lon, acc) VALUES ('$jsonLocation[lat]', '$jsonLocation[prov]', '$jsonLocation[lon]', '$jsonLocation[acc]')"; $enterLocation = mysql_query($sql_location) or die("Failure in location!"); </code></pre> <p>Thanks again!</p> <p>Case closed.</p> <p>PS: The structure of the JSON-Data. You get it by using "print_r()" or "var_dump()".</p> <pre><code>( [id] =&gt; bf75b277-169b-49da-8ab1-b78b80f51b43-e25c7f28b3 [ts] =&gt; 1372751172664 [connected] =&gt; Array ( [ssid] =&gt; eduroam [bssid] =&gt; 00:0f:f7:eb:08:81 [rssi] =&gt; -62 [speed] =&gt; 54 ) [configured] =&gt; Array ( [0] =&gt; Array ( [ssid] =&gt; eduroam [bssid] =&gt; null [keyMgmnt] =&gt; Array ( [0] =&gt; 2 [1] =&gt; 3 ) [grCiphers] =&gt; Array ( [0] =&gt; 0 [1] =&gt; 1 [2] =&gt; 2 [3] =&gt; 3 ) ) [1] =&gt; Array ( [ssid] =&gt; foobar [bssid] =&gt; null [keyMgmnt] =&gt; Array ( [0] =&gt; 0 ) [grCiphers] =&gt; Array ( [0] =&gt; 0 [1] =&gt; 1 [2] =&gt; 2 [3] =&gt; 3 ) ) ) [location] =&gt; Array ( [prov] =&gt; network [lat] =&gt; 52.3793203 [lon] =&gt; 9.7231332 [acc] =&gt; 22.777 ) ) ( [id] =&gt; bf75b277-169b-49da-8ab1-b78b80f51b43-e25c7f28b3 [ts] =&gt; 1372751172664 [connected] =&gt; Array ( [ssid] =&gt; eduroam [bssid] =&gt; 00:0f:f7:eb:08:81 [rssi] =&gt; -62 [speed] =&gt; 54 ) [configured] =&gt; Array ( [0] =&gt; Array ( [ssid] =&gt; eduroam [bssid] =&gt; null [keyMgmnt] =&gt; Array ( [0] =&gt; 2 [1] =&gt; 3 ) [grCiphers] =&gt; Array ( [0] =&gt; 0 [1] =&gt; 1 [2] =&gt; 2 [3] =&gt; 3 ) ) [1] =&gt; Array ( [ssid] =&gt; foobar [bssid] =&gt; null [keyMgmnt] =&gt; Array ( [0] =&gt; 0 ) [grCiphers] =&gt; Array ( [0] =&gt; 0 [1] =&gt; 1 [2] =&gt; 2 [3] =&gt; 3 ) ) ) [location] =&gt; Array ( [prov] =&gt; network [lat] =&gt; 52.3793203 [lon] =&gt; 9.7231332 [acc] =&gt; 22.777 ) ) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload