|
|
|
สอบถามเกี่ยวกับ google map ลง เว็ปของเราโดยจะเอาค่าพิกัดมาจากฐานข้อมูลอะครับ |
|
|
|
|
|
|
|
Code (PHP)
<?php require_once('Connections/dtc2.php'); ?>
<?php
mysql_select_db($database_dtc2, $dtc2);
$query_Recordset1 = "SELECT * FROM station";
$Recordset1 = mysql_query($query_Recordset1, $dtc2) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<html>
<head>
<title></title>
<script src="http://maps.google.com/maps?file=api&v=2&sensor=true&key=ABQIAAAAYM28F9SN3TAbl0OAuyHMmRT2yXp_ZAY8_ufC3CFXhHIE1NvwkxSGok6nBuj_8mwpyzy2xKwy8T-nag" type="text/javascript"></script>
<script type="text/javascript">
function initialize() {
var map = new GMap2(document.getElementById("map"));
//ใส่ค่าละติจูด , ลองติจูด , ระยะการซูม
map.setCenter(new GLatLng(13.673343,100.606484), 15);
map.setUIToDefault();
}
</script>
<script language="JavaScript">
function MoveOption(objSourceElement, objTargetElement) {
var aryTempSourceOptions = new Array();
var x = 0;
for (var i = 0; i < objSourceElement.length; i++) {
if (objSourceElement.options[i].selected) {
var intTargetLen = objTargetElement.length++;
objTargetElement.options[intTargetLen].text = objSourceElement.options[i].text;
objTargetElement.options[intTargetLen].value = objSourceElement.options[i].value;
}
else {
var objTempValues = new Object();
objTempValues.text = objSourceElement.options[i].text;
objTempValues.value = objSourceElement.options[i].value;
aryTempSourceOptions[x] = objTempValues;
x++;
}
}
objSourceElement.length = aryTempSourceOptions.length;
for (var i = 0; i < aryTempSourceOptions.length; i++) {
objSourceElement.options[i].text = aryTempSourceOptions[i].text;
objSourceElement.options[i].value = aryTempSourceOptions[i].value;
objSourceElement.options[i].selected = false;
}
}
function checkAllItems()
{
for (var i = 0; i < frmMain.ddlLeft.length; i++) {
frmMain.ddlLeft.options[i].selected = true;
}
for (var i = 0; i < frmMain.ddlRight.length; i++) {
frmMain.ddlRight.options[i].selected = true;
}
}
function removeAllItems()
{
for (var i = 0; i < frmMain.ddlLeft.length; i++) {
frmMain.ddlLeft.options[i].selected = false;
}
for (var i = 0; i < frmMain.ddlRight.length; i++) {
frmMain.ddlRight.options[i].selected = false;
}
}
function moveAllItems()
{
for (var i = 0; i < frmMain.ddlLeft.length; i++) {
frmMain.ddlLeft.options[i].selected = true;
}
for (var i = 0; i < frmMain.ddlRight.length; i++) {
frmMain.ddlRight.options[i].selected = true;
}
}
</script>
</head>
<body onload="initialize()" onunload="GUnload()">
<body onLoad="removeAllItems();">
<form name="frmMain" action="AddRemoveItems.php" method="post" onSubmit="checkAllItems();">
<table width="353" border="0" cellspacing="4" cellpadding="0">
<!--DWLayoutTable-->
<tr>
<td width="105" height="221" valign="top">
<select name="ddlLeft[]" id="ddlLeft" size="12" multiple style="width: 150px;">
<?php
do {
?>
<option value="<?php echo $row_Recordset1['station_name']?>"<?php if (!(strcmp($row_Recordset1['station_name'], $row_Recordset1['station_name']))) {echo "selected=\"selected\"";} ?>><?php echo $row_Recordset1['station_name']?></option>
<?php
} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
$rows = mysql_num_rows($Recordset1);
if($rows > 0) {
mysql_data_seek($Recordset1, 0);
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
}
?>
</select></td>
<td width="126"><div align="center">
<input type="button" name="MoveRight" value=" > " style="width: 120px;" onClick="MoveOption(this.form.ddlLeft, this.form.ddlRight)">
<br>
<br>
<input type="button" name="MoveLeft" value=" < " style="width: 120px;" onClick="MoveOption(this.form.ddlRight, this.form.ddlLeft)">
<br>
<br>
<input name="allMoveRight2" type="button" id="allMoveRight2" style="width: 120px;" onClick="moveAllItems(this.form.ddlLeft, this.form.ddlRight)" value=" >> move all ">
<br>
<br>
<input name="allMoveLeft2" type="button" id="allMoveLeft2" style="width: 120px;" onClick="moveAllItems" value="<< move all">
<br>
<br>
<br>
<input name="btnSubmit" type="submit" id="btnSubmit" value="Submit">
</div></td>
<td width="106" valign="top">
<select name="ddlRight[]" id="ddlRight" size="12" multiple style="width: 150px;">
</select></td>
</tr>
</table>
<p> </p>
<table width="100%" border="4">
<tr bgcolor="#CCFF99">
<td><div align="center"><strong>Station_ID</strong></div></td>
<td><div align="center"><strong>Station_Name</strong></div></td>
<td><p align="center"><strong>S_Lat</strong></p> </td>
<td><div align="center"><strong>S_Lon</strong></div></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
<p> </p>
<div id="map" style="width: 640px; height: 480px">
<p> </p>
<p> </p>
</div>
<p></p>
</form></body></html>
<?php
mysql_free_result($Recordset1);
?>
</body>
</html>
Tag : PHP, MySQL
|
|
|
|
|
|
Date :
2011-04-24 10:28:33 |
By :
004 |
View :
804 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|