我有问题从html获取文本字段的值到php。
我想创建一个select语句来从mysql数据库中按日期过滤纬度和经度,但该语句不起作用。 $_Post[datee];
未从文本框中获取值。
这是我的代码:
<?php
$dbname ='u769748933_tr'; //Name of the database
$dbuser ='u769748933_ta'; //Username for the db
$dbpass ='adamas'; //Password for the db
$dbserver ='mysql.1freehosting.com'; //Name of the mysql server
$dbcnx = mysql_connect ("$dbserver", "$dbuser", "$dbpass");
mysql_select_db("$dbname") or die(mysql_error());
?>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Google Map API V3 with markers</title>
<style type="text/css">
body { font: normal 10pt Helvetica, Arial; }
#map { width: 350px; height: 300px; border: 0px; padding: 0px; }
</style>
<script src="http://maps.google.com/maps/api/js?v=3&sensor=false" type="text/javascript"></script>
<script type="text/javascript">
var icon = new google.maps.MarkerImage("http://maps.google.com/mapfiles/ms/micons/blue.png",
new google.maps.Size(32, 32), new google.maps.Point(0, 0),
new google.maps.Point(16, 32));
var center = null;
var map = null;
var currentPopup;
var bounds = new google.maps.LatLngBounds();
function addMarker(lat, lng, info) {
var pt = new google.maps.LatLng(lat, lng);
bounds.extend(pt);
var marker = new google.maps.Marker({
position: pt,
icon: icon,
map: map
});
var popup = new google.maps.InfoWindow({
content: info,
maxWidth: 300
});
google.maps.event.addListener(marker, "click", function() {
if (currentPopup != null) {
currentPopup.close();
currentPopup = null;
}
popup.open(map, marker);
currentPopup = popup;
});
google.maps.event.addListener(popup, "closeclick", function() {
map.panTo(center);
currentPopup = null;
});
}
function initMap() {
map = new google.maps.Map(document.getElementById("map"), {
center: new google.maps.LatLng(0, 0),
zoom: 14,
mapTypeId: google.maps.MapTypeId.ROADMAP,
mapTypeControl: false,
mapTypeControlOptions: {
style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR
},
navigationControl: true,
navigationControlOptions: {
style: google.maps.NavigationControlStyle.SMALL
}
});
<?
$date=$_POST['datee'];
$query = mysql_query("SELECT * FROM poi_example where datee='".$date."'");
while ($row = mysql_fetch_array($query)){
$name=$row['name'];
$lat=$row['lat'];
$lon=$row['lon'];
$desc=$row['desc'];
echo ("addMarker($lat, $lon,'<b>$name</b><br/>$desc');\n");
}
?>
center = bounds.getCenter();
map.fitBounds(bounds);
}
</script>
</head>
<body style="margin:0px; border:0px; padding:0px;">
<button onclick="initMap()">show map</button>
<INPUT TYPE = "Text" NAME = "datee">
<div id="map"></div>
</html>
答案 0 :(得分:0)
您错过了<form method="POST">
代码
答案 1 :(得分:0)
像这样创建你的
sklearn_pca.explained_variance_ratio_
然后在PHP中获取这些值,如<form method="POST">
<!-- input fields here -->
</form>
答案 2 :(得分:0)
只需在以下代码行中添加<form>
标记
<button onclick="initMap()">show map</button>
<INPUT TYPE = "Text" NAME = "datee">
像这样,
<form method="POST">
<input type="text" name="date" placeholder="Enter Date">
<button type="submit" onclick="initMap()">show map</button>
</form>
表单标记用于创建用户输入的表单。
答案 3 :(得分:0)
您需要在input
个代码中使用form
s。此外,您需要定义表单method
(如果没有给出,它将设置为GET
)。
因此,您的代码应如下所示:
<form method="POST">
<button onclick="initMap()">show map</button>
<input type= "Text" NAME = "datee">
</form>