HEX
Server: Apache
System: Linux b:u:marcbase:1 3.10.0-1160.31.1.el7.x86_64 #1 SMP Thu Jun 10 13:32:12 UTC 2021 x86_64
User: apache (92344)
PHP: 7.0.18
Disabled: apache_get_modules, apache_get_version, apache_reset_timeout, apache_getenv, apache_note, apache_setenv
Upload Files
File: /var/www/html/marcbase.com.br/web/DBsimplified/php_scripts/seeklatmin.php
<?php
/*
Our "config.inc.php" file connects to database every time we include or require
it within a php script.  Since we want this script to add a new user to our db,
we will be talking with our database, and therefore,
let's require the connection to happen:
*/
require("config.inc.php");

//filtrando between
$latmin= $_POST['latmin'];
$latmax= $_POST['latmax'];
$longmin= $_POST['longmin'];
$longmax= $_POST['longmax'];

//$query = "SELECT * FROM retrofit_users WHERE (latitude>'$latmin') AND (latitude<'$latmax') AND (longitude>'$longmin') AND (longitude<'$longmax')";
//latmin: -25      latmax : -23    longmin: -48     longmax: -46   
//$query = "SELECT * FROM retrofit_users WHERE (latitude>'$latmin') AND (latitude<'$latmax') ";
$query = "SELECT * FROM retrofit_users WHERE (latitude>'$latmin') AND (latitude<'$latmax') AND (longitude>'$longmin') AND (longitude<'$longmax') ORDER BY name DESC";

//echo '   latmin  ';
//echo $latmin;
//echo '   latmax';
//echo $latmax;
//echo '   longmin ';
//echo $longmin;
//echo '   longmax ';
//echo $longmax;

//execute query
try {
    $stmt   = $db->prepare($query);
    $result = $stmt->execute($query_params);
}
catch (PDOException $ex) {
    $response["success"] = 0;
    $response["message"] = "Database Error!";
    die(json_encode($response));
}

// Finally, we can retrieve all of the found rows into an array using fetchAll 
$rows = $stmt->fetchAll();


if ($rows) {
    $response["success"] = 1;
    $response["message"] = "Post Available!";
    $response["posts"]   = array();
    
    foreach ($rows as $row) {
        $post             = array();
		$post["id"]  = $row["id"];
        $post["name"] = $row["name"];
        $post["username"]    = $row["username"];
        $post["email"]  = $row["email"];
		$post["latitude"]  = $row["latitude"];
		$post["longitude"]  = $row["longitude"];
        
        
        //update our repsonse JSON data
        array_push($response["posts"], $post);
    }
    
    // echoing JSON response
    echo json_encode($response);
    
    
} else {
    $response["success"] = 0;
    $response["message"] = "No Post Available!";
    die(json_encode($response));
}

?>