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/seeklatminOK.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");


$typeplaceitem = $_POST['typeplace']; // dentro da postagem de TAG typeplace vira Bar, Restaurant etc
$filterarea= $_POST['state'];  // depois criaremos a coluna maincityarea que substituira o estado
$filtercity= $_POST['city']; // depois faremos um if criando um query para cidades
$filtermenu= $_POST['filtermenu'];

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

//latmin: -22.911977       latmax : -22.905294     longmin: -46.993739     longmax: -46.889848   
$query = "SELECT * FROM business WHERE (lat>'$latmin') AND (lat<'$latmax') AND (longit>'$longmin') AND (longit<'$longmax') ORDER BY scoretotal DESC"; // AND longit BETWEEN  $longmin AND $longmax; //AND placetype  bar


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["businessname"] = $row["businessname"];
        $post["city"]    = $row["city"];
        $post["scoretotal"]  = $row["scoretotal"];
		$post["lat"]  = $row["lat"];
		$post["longit"]  = $row["longit"];
		
		
        
        
        //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));
}

?>