This question already has an answer here:
using PHP & MYSQL on WordPress and Google Map API in order to retrieve data from MYSQL database and display markers with info windows on Google Map.
problem is that the map doesn't appear on the webpage, yet the SQL query is retrieving the required data.
where i have SQL query:
that retrieve data and display it in table
{
position: new google.maps.LatLng(33.8533166667, 35.5077833333),
info:'BIS001',
height: '48',
site_name: Bissan',
}
,{
position: new google.maps.LatLng(33.8533166667, 35.5077833333),
info:'BIS002',
height: '48',
site_name: Bissan',
}
,{
position: new google.maps.LatLng(33.8533166667, 35.5077833333),
info:'BIS003',
height: '48',
site_name: Bissan',
}
this what must be displayed on the web page the system display instead just the last value:
Bissan Fadi El Moussawi gds BIS003
how to make the system or the query display all the required records?
<?php
// code for submit button action
global $wpdb, $site_name;
//variables that handle the retrieved data from mysql database based on the ID of the variable in HTML (select)
if(isset($_POST['query_submit']))
{
if(isset($_POST['site_name']))
{
$site_name=$_POST['site_name'];
}
else { $site_name=""; }
if(isset($_POST['owner_name']))
{
$owner_name=$_POST['owner_name'];
}
else { $owner_name=""; }
if(isset($_POST['Company_name']))
{
$company_name=$_POST['Company_name'];
}
else { $company_name=""; }
if(isset($_POST['Subcontractor_name']))
{
$Subcontractor_name=$_POST['Subcontractor_name'];
}
else { $Subcontractor_name="";}
// var_dump($site_name);
$sql = $wpdb->prepare("select i.siteID
, i.siteNAME
, i.equipmentTYPE
, c.latitude
, c.longitude
, c.height
, o.ownerNAME
, o.ownerCONTACT
, x.companyNAME
, y.subcontractorCOMPANY
, y.subcontractorNAME
, y.subcontractorCONTACT
from site_info i
LEFT
JOIN owner_info o
on i.ownerID = o.ownerID
LEFT
JOIN company_info x
on i.companyID = x.companyID
LEFT
JOIN subcontractor_info y
on i.subcontractorID = y.subcontractorID
LEFT JOIN site_coordinates2 c
on i.siteID=c.siteID
where
i.siteNAME = %s
AND
o.ownerNAME = %s
AND
x.companyNAME = %s
",$site_name,$owner_name,$company_name);
$query_submit =$wpdb->get_results($sql, OBJECT);
echo "<br>";
echo "<br>";
//echo $sql;
// var_dump($_POST['site_name']);
foreach ($query_submit as $obj) {
$obj->siteNAME;
$obj->ownerNAME;
$obj->companyNAME;
$obj->subcontractorNAME;
$obj->siteID;
$obj->equipmentTYPE;
$obj->latitude;
$obj->longitude;
$obj->height;
$obj->ownerCONTACT;
$obj->subcontractorCONTACT;
$obj->subcontractorCOMPANY;
}
// table that will dsiplay the results based on the user's selection //
echo "<table width='30%' ";
echo "<tr>";
echo "<td>Site Name</td>";
echo "<td>Owner Name</td>";
echo "<td>Company Name</td>";
echo "<td>Subcontractor Name</td>";
echo "<td>Site ID</td>";
echo "<td>Equipment Type</td>";
echo "<td> Lattitude</td>";
echo "<td>Longitude </td>";
echo "<td> Height</td>";
echo "<td> Owner Contact</td>";
echo "<td> Sub Contact</td>";
echo "<td> Sub company Name</td>";
echo "</tr>";
echo "<tr>";
echo "<td>".$obj->siteNAME."</td>";
echo "<td>".$obj->ownerNAME."</td>";
echo "<td>".$obj->companyNAME."</td>";
echo "<td>".$obj->subcontractorNAME."</td>";
echo "<td>".$obj->siteID."</td>";
echo "<td>".$obj->equipmentTYPE."</td>";
echo "<td>".$obj->latitude."</td>";
echo "<td>".$obj->longitude."</td>";
echo "<td>".$obj->height."</td>";
echo "<td>".$obj->ownerCONTACT."</td>";
echo "<td>".$obj->subcontractorCONTACT."</td>";
echo "<td>".$obj->subcontractorCOMPANY."</td>";
echo "</tr>";
echo "<tr>";
echo "<td>";
?>
</div>
The text identifier (') right before 'Bissan' is always missing. Try it with text identifier before and after the string. Like that:
{
position: new google.maps.LatLng(33.8533166667, 35.5077833333),
info:'BIS001',
height: '48',
site_name: 'Bissan',
}
,{
position: new google.maps.LatLng(33.8533166667, 35.5077833333),
info:'BIS002',
height: '48',
site_name: 'Bissan',
}
,{
position: new google.maps.LatLng(33.8533166667, 35.5077833333),
info:'BIS003',
height: '48',
site_name: 'Bissan',
}