Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8577835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:14:56+00:00 2026-06-11T20:14:56+00:00

I have a heat map application on OpenLayers where user enters two date and

  • 0

I have a heat map application on OpenLayers where user enters two date and time intervals and selects whether he/she would like to view all the data between those two datetimes or view them based on hourly/daily/weekly/monthly intervals. However, when I type in two date and times as input and try to visualize the data, I can only visualize all the data between those two intervals. Whenever I choose hourly, daily, weekly etc from my HTML drop down menu and press fetch queries button, I get an Error in Ajax POST message. What could be the cause here? The codes are below:

The HTML Post part:

$(document).ready(function(){

 // ajaxForm submission
 $('#ajaxForm').submit(function() {
  $.ajax({
   type: 'POST',
   url: 'heatQuery.php',
   //url: 'http://localhost/heatQuery.php',
   data: $(this).serialize(),
   dataType: 'json',
   success: function(response)
   {   
       // update the points for heatmap layer          
       updateHeatMap(response);

   },
   error: function(errorMsg)
   {
       alert('Error in Ajax POST');
       }


  });

  return false;
 });
});

The PHP Part:

setupDB.php

<?php

$mysql_hostname = "localhost";
$mysql_user = "myuser";
$mysql_password = "mypassword";
$mysql_database = "mydatabase";
$bd = mysql_connect($mysql_hostname, $mysql_user) or die("Oops some thing went wrong");
    mysql_select_db($mysql_database, $bd) or die("Oops some thing went wrong");

?>

heatQuery.php

<?php
include 'setupDB.php';
$coords_array = array();

function getPoints($dateTimeBeg,$dateTimeEnd)
{
$ses_sql= "SELECT lat,lon FROM `mytable` WHERE calltime >= '$dateTimeBeg' AND calltime <= '$dateTimeEnd'";  
    $result = mysql_query($ses_sql,$bd) or die('Error: ' . mysql_error());
    if($result)
    {
        $num_of_rows = mysql_num_rows($result);
        if($num_of_rows > 0)
        {
            while($row = mysql_fetch_row($result))
            { 
                array_push($coords,array($row[0],$row[1]));     
            }
            array_push($coords_array,$coords);
        }
    }
}

$hours = array(1 => '00:00', '01:00', '02:00', '03:00', '04:00', '05:00', '06:00', '07:00', '08:00', '09:00', '10:00', '11:00', '12:00', '13:00', '14:00', '15:00', '16:00', '17:00', '18:00', '19:00', '20:00', '21:00', '22:00', '23:00', '24:00');

$dateBeg = isset($_POST['date1']) ? $_POST['date1'] : "";
$dateEnd = isset($_POST['date2']) ? $_POST['date2'] : "";
$dateFreq = isset($_POST['freq']) ? $_POST['freq'] : "";

if($dateBeg && $dateEnd && $dateFreq) // if all variables are set
{
    $datetime1 = new DateTime($dateBeg);
    $datetime2 = new DateTime($dateEnd);
    $interval = $datetime1->diff($datetime2,true);

    if($dateFreq == "all")
    {
        $coords = array();
        $timeBeg = $_POST['time1'];
        $timeEnd = $_POST['time2'];
        $sp = " ";
        $dateTimeBeg = $dateBeg.$sp.$timeBeg;
        $dateTimeEnd = $dateEnd.$sp.$timeEnd;
        $ses_sql= "SELECT lat,lon FROM `mytable` WHERE calltime >= '$dateTimeBeg' AND calltime <= '$dateTimeEnd'";  
    $result = mysql_query($ses_sql,$bd) or die('Error: ' . mysql_error());
    if($result)
    {
        $num_of_rows = mysql_num_rows($result);
        if($num_of_rows > 0)
        {
            while($row = mysql_fetch_row($result))
            { 
                array_push($coords,array($row[0],$row[1]));     
            }
            array_push($coords_array,$coords);
        }
    }

    }else if($dateFreq == "hourly")
    {       
        for($i=1;$i<=24;$i+=1)
        {
            $coords = array();
            $timeBeg = $hours[$i];
            $timeEnd = $hours[$i+1];
            $dateTimeBeg = $dateBeg.$sp.$timeBeg;
            $dateTimeEnd = $dateBeg.$sp.$timeEnd;
            $ses_sql= "SELECT lat,lon FROM `mytable` WHERE calltime >= '$dateTimeBeg' AND calltime <= '$dateTimeEnd'";  
    $result = mysql_query($ses_sql,$bd) or die('Error: ' . mysql_error());
    if($result)
    {
        $num_of_rows = mysql_num_rows($result);
        if($num_of_rows > 0)
        {
            while($row = mysql_fetch_row($result))
            { 
                array_push($coords,array($row[0],$row[1]));     
            }
            array_push($coords_array,$coords);
        }
    }

        }
    }else if($dateFreq == "daily")
    {
        for($i=1;$i<=interval;$i+=1)
        {
            $ses_sql= "SELECT lat,lon FROM `mytable` WHERE calltime >= '$dateTimeBeg' AND calltime <= '$dateTimeEnd'";  
    $result = mysql_query($ses_sql,$bd) or die('Error: ' . mysql_error());
    if($result)
    {
        $num_of_rows = mysql_num_rows($result);
        if($num_of_rows > 0)
        {
            while($row = mysql_fetch_row($result))
            { 
                array_push($coords,array($row[0],$row[1]));     
            }
            array_push($coords_array,$coords);
        }
    }
        }
    }

    $coords_json = json_encode($coords_array);
    echo $coords_json;

//echo $coords;

    mysql_close($bd);
}

?>

EDIT:

Per bPratik’s request, I’m also placing the alternative post error for HTML code that includes the error I get from the server:

error: function(jqXHR, textStatus, errorThrown)
   {

       alert('Error in Ajax POST\ntextStatus: ' + textStatus + '\nerrorThrown: ' + errorThrown);
    }

Despite putting this, I only get the Error in AJAX Post message. The weird thing is, the mysqld.exe process runs for a while -apparently it actually retrieves the queries meanwhile- and then I get the message.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T20:14:57+00:00Added an answer on June 11, 2026 at 8:14 pm

    Solved the issue some time ago, will post details soon.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to generate a heat map from an all-vs-all comparison. I have the
I have an iPhone application in the AppStore and I would like to analyze
I have some shapefile (demographic/heat map data in the USA, such as crime in
I have a code that calculates heat transfer in some number of conductors. What
What i have: I have an installations routine written in WIX 3.6 (with heat,
have written this little class, which generates a UUID every time an object of
have a problem. At first look at this HTML <div id=map style=background-image: url(map.png); width:
I am interested in creating a heat map of the stock market using internal
I need to create custom heat map as illustrated in the attached figure. It
I have an iPhone application that emails my GPS coordinates to an email account.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.