$q = "SELECT latitude_deg,longitude_deg,id FROM places;
$r = mysql_query($q);
$all = array();
while(($row = mysql_fetch_assoc($r))) {
$all[] = $row;
}
print json_encode($all);
I did not understand the question correctly it seems. Can you describe it more clearly what exactly you have, what exactly you expect to get as result.
$q = "SELECT ident,latitude_deg,longitude_deg FROM points";
$r = mysql_query($q);
$all = array();
while(($row = mysql_fetch_assoc($r))) {
$lat2=$row['latitude_deg'];
$lon2=$row['longitude_deg'];
$ident=$row['ident'];
// $all[] = distance('29','41',$lat2,$lon2,'N');
$arr[] = array('uzaklik' => distance('29','41',$lat2,$lon2,'N'), 'ident' => $ident);
}
print json_encode($arr);
$new = array_filter($arr, function ($var) {
return ($var['uzaklik'] > '500' and $var['uzaklik'] < '1500');
but you are not checking for this values as @ilan already stated. You are checking for STRING with 500 or 1500 in content.$value1 is 500 and $value2 is 1500
it is giving null when i use like that.i think int's should not be in '...'
just remove '
B4X:$value1 = 500 $value2 = 1500 $new = array_filter($arr, function ($var) { return ($var['uzaklik'] > $value1 and $var['uzaklik'] < $value2);
No luck with ilan's suggestion. Giving null :/but you are not checking for this values as @ilan already stated. You are checking for STRING with 500 or 1500 in content.
No luck with ilan's suggestion. Giving null :/
Case "24": //yakınklarıal
$usn = clean($_GET["girdi1"]);
$psw = md5(clean($_GET["girdi2"]));
$base = clean($_GET["girdi3"]);
$p1 = clean($_GET["girdi4"]);
$p2 = clean($_GET["girdi5"]);
$value1 = 500;
$value2 = 1500;
$q = "SELECT ident,latitude_deg,longitude_deg,iso_country,name FROM airports3";
// $q = "SELECT * FROM useraircrafts1 where username='".$usn."' order by date DESC";
$r = mysql_query($q);
$all = array();
while(($row = mysql_fetch_assoc($r))) {
$lat2=$row['latitude_deg'];
$lon2=$row['longitude_deg'];
$ident=$row['ident'];
$ulke=$row['iso_country'];
$name=$row['name'];
// $all[] = distance('29','41',$lat2,$lon2,'N');
$arr[] = array('uzaklik' => distance('41','26',$lat2,$lon2,'N'), 'ident' => $ident, 'ulke' => $ulke, 'name' => $name);
}
$uzaklik = array();
foreach ($arr as $key => $row2)
{
$uzaklik[$key] = $row2['uzaklik'];
}
array_multisort($uzaklik, SORT_ASC, $arr);
$new = array_filter($arr, function ($var) {
return ($var['uzaklik'] > '500' and $var['uzaklik'] < '1500');
});
print json_encode(array_slice($new, 0, 10000));
return ($var['uzaklik'] > '500' and $var['uzaklik'] < '1500');
$p1 = clean($_GET["girdi4"]);
$p2 = clean($_GET["girdi5"]);
$value1 = 500;
$value2 = 1500;
return ($var['uzaklik'] > $value1 and $var['uzaklik'] < $value2);
You are checking for STRING with 500 or 1500 in content.
it is giving null when i use like that.
It only works when they are in single quote and a value like i post :
$value1 = '500';
$value2 = '1500';
return ($var['uzaklik'] > '$value1' and $var['uzaklik'] < '$value2');
could it be that $var['uzaklik'] is not always a valid int?
if you do it like this:
B4X:$value1 = '500'; $value2 = '1500';
B4X:return ($var['uzaklik'] > '$value1' and $var['uzaklik'] < '$value2');
does it works??
if yes then $var['uzaklik'] is sometime (or always i don't know) a string and thats why you get a valid boolean returned because (a > b and a < c) =falsetrue
try to get a list of all your $var['uzaklik'] for every raw and see if all are valid ints
you can also do it in your php file (i mean the check if it is an int .. then...)
see this: http://php.net/manual/en/function.is-int.php
$uzaklik is just to filter the $arr to $new . Should i still dump it ? if yes how can i do it and how can i see it ? I just can see the json inside my app ?Dump the array to see the real types & values in the array:
B4X:var_dump($uzaklik)
$a = array(1, 2, array("a", "b", "c"));
var_dump($a);
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
array(3) {
[0]=>
string(1) "a"
[1]=>
string(1) "b"
[2]=>
string(1) "c"
}
}
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?