|
|
|
สอบถามปัญหาการส่งค่าจาก php ไปยังอีกไฟลฺ แต่ติดตรงที่ค่าไม่ส่งไปยัง php ของอีกไฟล์อ่ะคับ อ่ะคับ |
|
|
|
|
|
|
|
list.php
Code (PHP)
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<link href="../jquery-mobile/jquery.mobile-1.0.min.css" rel="stylesheet" type="text/css">
<script src="../jquery-mobile/jquery-1.6.4.min.js" type="text/javascript"></script>
<script src="../jquery-mobile/jquery.mobile-1.0.min.js" type="text/javascript"></script>
</head>
<body>
<div data-role="page" id="page">
<div data-role="header" data-theme="d">
<h1>Header</h1>
</div>
<div data-role="content">
<ul data-role="listview" data-inset="true" data-theme="d" data-divider-theme="e">
<li data-role="list-divider">Name</li>
<?
$objConnect = mysql_connect("localhost","root","") or die(mysql_error());
$objDB = mysql_select_db("test");
$strSQL = " SELECT ID,name FROM test";
$objQuery = mysql_query($strSQL) or die (mysql_error());
while($objResult = mysql_fetch_array($objQuery))
{
?>
<li><a href="location.php?ID=<?=$objResult["ID"];?>"><?=$objResult["name"];?></a></li>
<?
}
?>
</ul>
</div>
<div data-position="fixed" data-role="footer" data-theme="d">
<h4>Footer</h4>
</div>
</div>
</body>
</html>
location.php
Code (PHP)
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<link href="../jquery-mobile/jquery.mobile-1.0.min.css" rel="stylesheet" type="text/css">
<script src="../jquery-mobile/jquery-1.6.4.min.js" type="text/javascript"></script>
<script src="../jquery-mobile/jquery.mobile-1.0.min.js" type="text/javascript"></script>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
<?php
$con=mysqli_connect("localhost","root","","test");
//Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM position where ID = '".$_GET["ID"]."' ");
$row = mysqli_fetch_array($result);
$lat = $row['latitude'];
$log = $row['longitude'];
mysqli_close($con);
?>
<script>
function success(position) {
var lat = <?=$lat?>;
var lng = <?=$log?>;
var mapcanvas = document.createElement('div');
mapcanvas.id = 'mapcontainer';
mapcanvas.style.height = '485px';
mapcanvas.style.width = '100%';
mapcanvas.style.padding = '0px';
document.querySelector('article').appendChild(mapcanvas);
var coords = new google.maps.LatLng(lat,lng);
var options = {
zoom: 15,
center: coords,
mapTypeControl: false,
navigationControlOptions: {
style: google.maps.NavigationControlStyle.SMALL
},
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("mapcontainer"), options);
var marker = new google.maps.Marker({
position: coords,
map: map,
title:"You are here!"
});
}
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(success);
} else {
error('Geo Location is not supported');
}
</script>
</head>
<body>
<div data-role="page" id="page">
<div data-role="header" data-theme="d">
<h1>Header</h1>
</div>
<div data-role="content">
<div align="center">
<section id="wrapper" style="width:100%; height:100%;">
<article>
</article>
</section>
</div>
</div>
<div data-position="fixed" data-role="footer" data-theme="d">
<h4>Footer</h4>
</div>
</div>
</body>
</html>
ผมลองให้มัน echo $_GET["ID"];
ได้ undefined
ขอคำแนะนำหน่อยน่ะคับบ
ขอบคุณครับ =^^=
Tag : PHP, MySQL, HTML/CSS, jQuery, Android
|
|
|
|
|
|
Date :
2014-07-07 22:59:52 |
By :
DdoubleE |
View :
690 |
Reply :
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
คับจะลองดูคับ
|
|
|
|
|
Date :
2014-07-08 11:14:58 |
By :
DdoubleE |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ผมลองเอา jquery ออกจาก list.php ทำได้
แต่ผมจะทำเป็น app อ่ะคับ เลยจำเป็นต้องใช่ jqeury อะคับ พอจะมีวิธีแก้ไหมคับ
|
|
|
|
|
Date :
2014-07-08 11:50:01 |
By :
DdoubleE |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|