Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

Ok, at first:

Locations are stored in MySQL as a float - they have many decimal places (etc: 26.2332144332)

When I try to run my function (shown below) with finding proper locations

echo "<pre>";
print_r(fillItByRouteStats(48.7,21.3));
echo "</pre>";
  • everything is ok. An output will be:
  Array
    (
        [0] => Array
            (
                [0] => 48.7345055228826
                [1] => 21.393210697174027
            )
        [1] => Array
            (
                [0] => 48.797660505675985
                [1] => 21.30510963871461
            ) 
   etc...
    )

Functions are these:

function fillItByRouteStats($lat,$long){
   global $db;
   $int = 0;
   $array = array(array());
   $result = $db->query("SELECT * FROM reports WHERE latitude LIKE '$lat%' AND longtitude LIKE '$long%' ORDER BY datetime_view");
        while ($row = $db->fetch_array($result)){
            $array[$int][0] = $row['latitude'];
            $array[$int][1] = $row['longtitude'];
            $int++;
        }
    return $array;
}



function compareArrToSql($array){
        for($curr = 0; $curr<count($array)/2; $curr++){
            $sql_val = fillItByRouteStats($array[$curr],$array[$curr+1]);
            echo $array[$curr]. " -couples- " . $array[$curr+1]. "<br>";
            $curr++;
            print_r($sql_val);
                foreach ($sql_val as $key => $value) {
                    print_r($value);
                }
    }
}

And , now, when I use

compareArrToSql($arrayy)

with defined array, like this:

$arrayy[0]=48.7;
$arrayy[1]=21.3;
$arrayy[2]=48.62;
$arrayy[3]=21.31;

problem is here. Doesn't work. Array is empty, all print_r's from

compareArrToSql()

not showing. Why? where is the problem? is it my mistake or what?

share|improve this question
Is: 48.7 -couples- 21.3 printed? – Philip Whitehouse Sep 17 '12 at 1:38

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.