使用PHP& WordPress和Google Map API上的MYSQL,用于从MYSQL数据库中检索数据,并在Google Map上显示带有信息窗口的标记。
问题是地图没有出现在网页上,但SQL查询正在检索所需的数据。
我有SQL查询:
检索数据并将其显示在表格中
{
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',
}
这必须显示在系统显示的网页上,而不是最后一个值:
Bissan Fadi El Moussawi gds BIS003
如何让系统或查询显示所有必需的记录?
<?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>";
?>
答案 0 :(得分:0)
在Bissan&#39;之前的文字标识符(&#39;)总是缺少。 在字符串之前和之后尝试使用文本标识符。 像那样:
{
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',
}