I'm trying to get a JSON-file looking like this: - [
-
[
-
'Disease', [ latitude, longitude, magnitude, latitude, longitude, magnitude, ... ]
-
],
-
[
-
'Disease', [ latitude, longitude, magnitude, latitude, longitude, magnitude, ... ]
-
]
-
];
This is the current code: - $sqlDisease = mysql_query("SELECT DISTINCT Disease FROM DiseaseData") or die(mysql_error());
-
-
$result = [];
-
while($rowDisease = mysql_fetch_assoc($sqlDisease)){
-
$theDisease = $rowDisease['Disease'];
-
$sqlData = mysql_query("
-
SELECT lat, lng, magnitude
-
FROM DiseaseData
-
WHERE Disease = '".mysql_real_escape_string($theDisease)."'")
-
or die(mysql_error());
-
$data = [];
-
while($rowData = mysql_fetch_row($sqlData)){
-
$data[] = $rowData;
-
}
-
$mergedData = call_user_func_array( 'array_merge', $data );
-
$result[] = [$theDisease, $mergedData];
-
}
-
-
$json = json_encode($result);
-
$file = 'testRes.json';
-
file_put_contents($file, $json);
I get a JSON-file in the right format, but there's two problems. It seems like WHERE Disease = '".mysql_real_e scape_string($t heDisease)."' do not select distinct values and $data[] keeps growing.
Here's a sample how it looks with current code: - [
-
["Malaria", ["40.555", "-122.222", "0.5", "85.111", "-33.4444", "0.7"]],
-
["HIV", ["40.555", "-122.222", "0.5", "85.111", "-33.4444", "0.7",
-
"40.555", "-122.222", "0.5", "85.111", "-33.4444", "0.7"]]
-
]
1 1370 Dormilich 8,658
Recognized Expert Moderator Expert Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Michael Iatauro |
last post by:
I've been having a little trouble creating users cross-platform. I have
a little script that works just fine on Solaris 8 using this command:
eval "/path/to/mysql --user=root --password=*****
--socket=/path/to/socket --database=mysql --execute=\"INSERT INTO user
(Host, User, Password, Select_priv, Insert_priv, Update_priv,
Delete_priv, Shutdown_priv, File_priv, Create_tmp_table_priv,
Lock_tables_priv) VALUES ('localhost', 'LocalUser',...
|
by: Paul Auleciems |
last post by:
Hi:
I'm having trouble using an Object which is created based on the following:
Public CarDetail () as Car
Where the CLASS "Car" is defined as:
Public Class Car
|
by: elixxir |
last post by:
Hiho,
I'm trying to deserialize the following XML feed from the weather
channel but I'm having an issue with the nested arrays. I got as far as
getting the 'day' into arrays but I can't get the 'part' nested array
working.
This is my first hack at XML feeds and such, so any pointers as to how
to best do this or references/tutorials would be good.
(I'm doing all this in .NET 2.0 btw)
|
by: StuartJ |
last post by:
Hi,
I'm trying to create a generic threading application where you can pass
in any object and a number of threads, most of it is working but I'm
having trouble creating multiple instances of the object handed down.
The code that I've supplied should simply create msgbox with 10
different messages, but it the ProcessID gets incremented for all the
threads everytime a new object is created.
|
by: Saint48198 |
last post by:
I'm having trouble with an array of data created using the 'getElementsByTagName' call. I'm trying to remove duplicates from the Array. code follows:
// creates a list of all keywords and the removes any dublicates and printes the results
getKeywords : function() {
var keywords = articleHolder.getElementsByTagName('span');
var savedKeywords = ;
for (var i =0, allKeywords = keywords.length; i<allKeywords; i++) {...
| |
by: 4Ankit |
last post by:
hey guys i am having trouble changing my array code to include a 'for/
in' structure
the code i am trying to change is below:
<script type="text/javascript">
var contents = new Array(3)
|
by: phil.swenson |
last post by:
I'm using Prototype.js and would like to convert the contents of an
HTML table to JSON. Converting to an array first is fine too. Any
thoughts on this? I haven't seen anyone do anything this....
thanks
phil
|
by: stevedub |
last post by:
I am having some trouble configuring my array to read from a sequential file, and then calling on that to fill an array of interests. I think I have the class set up to read the file, but when I run my program the rates array does not get the information. I think my problem is where I am actuall calling the array index, but I am not sure how to do this. Here is my code:
/*
* MortFrame.java
*
* Created on February 24, 2008, 7:28 PM
*/...
|
by: lawpoop |
last post by:
Hello all -
Is there a way to get a nested array in a $_POST variable?
I have a form where there are several questions, each one
corresponding to a database row. On submission of the form, I loop
through the $_POST array, and update the database appropriately.
So my post variable looks like this:
|
by: mouac01 |
last post by:
Let's say I have this MySQL table.
Year Region Amount
2007 West 100
2007 East 200
2007 North 300
2007 South 400
2008 West 500
2008 East 600
2008 North 700
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| | |