I'm working with a .php file containing HTML, PHP and Javascript and a table named data in MySQL which contains GPS info ordered by date. I'm using the following code so an user can type a date in a form.
<form method="POST">
<div class="col-sm-12">
<p>
<label for="route_date_ids">Insert date</label>
<input name="route_date_id"></input>
</p>
</div>
<div class="col-sm-12">
<p>
<input type="submit" value="View route"/>
</p>
</div>
</form>
<?php if (isset($_POST['route_date_id'])) : ?>
<?php
$query = "SELECT * FROM data WHERE measured_at LIKE ". $_POST['route_date_id'];
$result = mysqli_query($conn, $query);
so once the user type a date and press the button, on the server side, I get the data whose date starts with the characters the user typed. My objetive now is to pass that information ($result, which contains latitude and longitude data) to the following function.
function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 3,
center: {lat: 0, lng: -180},
mapTypeId: 'terrain'
});
var flightPlanCoordinates = [
{lat: 37.772, lng: -122.214},
{lat: 21.291, lng: -157.821},
{lat: -18.142, lng: 178.431},
{lat: -27.467, lng: 153.027}
];
var flightPath = new google.maps.Polyline({
path: flightPlanCoordinates,
geodesic: true,
strokeColor: '#FF0000',
strokeOpacity: 1.0,
strokeWeight: 2
});
flightPath.setMap(map);
}
so when the page is reloaded after the submit, the map shows the coordinates corresponding to the date the user typed.
I cannot solve this last question. Any help would be appreciated.