I'm doing an android application which queries a database to get the name of several sports. The query I do is the following:
if($resultset=getSQLResultSet("SELECT etiqueta_nombre from sdo_v_etiquetas_espacios GROUP BY etiqueta_nombre")){
while ($row = $resultset->fetch_array(MYSQLI_NUM)){
echo json_encode($row);
}
}
And it returns the following result: ["Futbol"]["Tenis"]
.
The code that implements the data extraction after the query that I have done is:
protected void onPostExecute(String result) {
JSONArray ja = null;
try {
ja = new JSONArray(result);
if(!ja.isNull(0)){
for(int i=0;i<ja.length();i++)
etiquetas.add(ja.getString(i).toString());
}
} catch (JSONException e) {
e.printStackTrace();
}
}
The problem is that it only returns the first one and if I try to put a for
with the length of ja.length()
it returns a OutOfIndex
.