|
|
|
สอบถาม เรื่องการเชื่อมต่อหน้า และการส่งค่าจาก php ไปแสดงที่หน้า html อีกหน้า |
|
|
|
|
|
|
|
แบบนี้ คงต้องใช้เทคนิค Ajax แล้วครับผม ลองดูครับ
jquery-ajax-ajax
|
|
|
|
|
Date :
2014-10-28 14:32:58 |
By :
Manussawin |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
คือแบบนี้อ่ะครับ
Code (PHP)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title> Input Data </title>
<link rel="stylesheet" href="home.css"/>
</head>
<body>
<header>
<h1> Airnet Intelligence Installation </h1>
</header>
<aside>
</aside>
<section>
<form action="compare.php" method="post">
<table border=0>
<tr> <td> Latitude </td> <td> <input id="lat" name="lat" type="text" /> </td> </tr>
<tr> <td> Longtitude </td> <td> <input id="long" name="long" type="text"/> </td> </tr>
<tr> <td> <li> Distance </td> <td> <input id="distance" name="distance" type="text" /> km </td> </tr>
</table>
<!-- <input type="hidden" name="number" value=""/> -->
<input class="submit" type="submit" value="submit"/>
</form>
</section>
</body>
</html>
โดยผมส่งค่าที่ได้ใส่ข้อมูลไป ที่หน้า compare
compare(PHP)
<?php
define('db_host','localhost');
define('db_password','');
define('db_user','root');
define('db_name','project');
//include("home.html");
$distance = $_POST['distance'];
$lat = $_POST['lat'];
$long = $_POST['long'];
$lat_rad1 = deg2rad($lat);
$long_rad1 = deg2rad($long);
$radius = 6371;
$maxlat = $lat + rad2deg($distance/$radius);
$minlat = $lat - rad2deg($distance/$radius);
$maxlong = $long + rad2deg($distance/$radius/cos(deg2rad($lat)));
$minlong = $long - rad2deg($distance/$radius/cos(deg2rad($lat)));
session_start();
mysql_connect(db_host,db_user,db_password) or die("Failed to connect to Mysql".mysql_error());
mysql_select_db(db_name) or die("Failed to connect to Mysql".mysql_error());
$sql = "SELECT * FROM ap_position where latitude between $minlat and $maxlat
AND longtitude between $minlong and $maxlong ";
$query = mysql_query($sql);
if(!$query)
{
echo"เกิดข้อผิดพลาดในการอ่านข้อมูล";
}
else if(mysql_num_rows($query)==0)
{
echo "ไม่มีข้อมูลที่ท่านต้องการ";
}
else
{
//echo "<table border=1 cellpadding=3 align=left width=700>";
/*
echo"<tr>";
echo"<th> No. </th>
<th> AP_Name </th>
<th> Distance </th>
<th> Direction </th>";
echo"</tr>";
*/
$i=0;
while($result = mysql_fetch_array($query))
{
// คำนวณมุม
if (((($lat - $result['latitude']) * ($lat - $result['latitude'])) + (($long - $result['longtitude']) * ($long - $result['longtitude']))) <= ($distance * $distance))
{
switch($result['sector'])
{
case 12:
{
if (($result['latitude'] <= $lat) && ($result['longtitude'] <= $long))
{
$radians = atan2($lat - $result['latitude'],$long - $result['longtitude']);
$degree = (float)($radians * (180/pi()));
$real_degree = 180 +(90 - $degree);
}
else
{
$real_degree="ไม่สามารถให้บริการได้";
}
}
break;
case 23:
{
if (($long >= $result['longtitude']) && ((($result['longtitude'] - $long) * ($result['longtitude'] - $long)) >= (($lat - $result['latitude']) * ($lat - $result['latitude']))))
{
if ($result['latitude'] >= $lat)
{
$radians = atan2($result['latitude'] - $lat , $long - $result['longtitude']);
$degree = (float)($radians * (180 / pi()));
$real_degree = 270 + $degree;
}
elseif($result['latitude'] <= $lat)
{
$radians = atan2($lat - $result['latitude'], $long - $result['longtitude']);
$degree = (float)($radians * (180 / pi()));
$real_degree = 180 + (90 - $degree);
}
}
else
{
$real_degree="ไม่สามารถให้บริการได้";
}
}
break;
case 34:
{
if (($result['latitude'] >= $lat) && ($result['longtitude'] <= $long))
{
$radians = atan2($result['latitude'] - $lat , $long - $result['longtitude']);
$degree = (float)($radians * (180 / pi()));
$real_degree = 270 + $degree;
}
else
{
$real_degree="ไม่สามารถให้บริการได้";
}
}
break;
case 45:
{
if (($lat <= $result['latitude']) && ((($result['latitude'] - $lat) * ($result['latitude'] - $lat)) >= (($long - $result['longtitude']) * ($long - $result['longtitude']))))
{
if ($result['longtitude'] >= $long)
{
$radians = atan2($result['latitude'] - $lat , $result['longtitude'] - $long);
$degree = (float)($radians * (180 / pi()));
$real_degree = 90 - $degree;
}
elseif($result['longtitude'] <= $long)
{
$radians = atan2($result['latitude'] - $lat , $long - $result['longtitude']);
$degree = (float)($radians * (180 / pi()));
$real_degree = 270 + $degree;
}
}
else
{
$real_degree="ไม่สามารถให้บริการได้";
}
}
break;
case 56:
{
if (($result['latitude'] >= $lat) && ($result['longtitude'] >= $long))
{
$radians = atan2($result['latitude'] - $lat , $result['longtitude'] - $long);
$degree = (float)($radians * (180 / pi()));
$real_degree = 90 - $degree;
}
else
{
$real_degree="ไม่สามารถให้บริการได้";
}
}
break;
case 67:
{
if (($long <= $result['longtitude']) && ((($result['longtitude'] - $long) * ($result['longtitude'] - $long)) >= (($lat - $result['latitude']) * ($lat - $result['latitude']))))
{
if ($result['latitude'] >= $lat)
{
$radians = atan2($lat - $result['latitude'], $long - $result['longtitude']);
$degree = (float)($radians * (180 / pi()));
$real_degree = 90 - $degree;
}
elseif($result['latitude'] <= $lat)
{
$radians = atan2($lat - $result['latitude'] , $resutl['longtitude'] - $long);
$degree = (float)($radians * (180 / pi()));
$real_degree = 90 + $degree;
}
}
else
{
$real_degree="ไม่สามารถให้บริการได้";
}
}
break;
case 78:
{
if (($result['latitude'] <= $lat) && ($result['longtitude'] >= $long))
{
$radians = atan2($lat - $result['latitude'] , $result['longtitude'] - $long);
$degree = (float)($radians * (180 / pi()));
$real_degree = 90 + $degree;
}
else
{
$real_degree="ไม่สามารถให้บริการได้";
}
}
break;
case 81:
{
if (($lat >= $result['latitude']) && ((($lat - $result['latitude']) * ($lat - $result['latitude'])) >= (($long - $result['longtitude']) * ($long - $result['longtitude']))))
{
if ($result['longtitude'] >= $long)
{
$radians = atan2($lat - $result['latitude'] , $result['longtitude'] - $long );
$degree = (float)($radians * (180 / pi()));
$real_degree = 90 + $degree;
}
elseif ($result['longtitude'] <= $long )
{
$radians = atan2($lat - $result['latitude'] , $long - $result['longtitude']);
$degree = (float)($radians * (180 / pi()));
$real_degree = 180 + (90 - $degree);
}
}
else
{
$real_degree="ไม่สามารถให้บริการได้";
}
}
break;
}
}
//คำนวณระยะทาง
$lat_rad2 = deg2rad($result['latitude']);
$long_rad2 = deg2rad ($result['longtitude']);
$dist = acos(sin($lat_rad1) * sin($lat_rad2) + cos($lat_rad1) * cos($lat_rad2) *cos($long_rad1 - $long_rad2));
$real_dist = $dist*$radius;
$i++;
/*
echo"<tr>";
echo"<td> $i </td>
<td> {$result['APname']} </td>
<td> $real_dist </td>
<td> $real_degree </td>";
echo"</tr>";
*/
}
//echo "</table>";
}
?>
ที่นี่ผมต้องการนำค่า $i , $result['APname'] $real_dist $real_degree พวกนี้อ่ะครับ ไปใช้อีกหน้านึง
ผมต้องใช้คำสั่งยังไงอ่ะครับ
ขอบคุณครับ
|
|
|
|
|
Date :
2014-10-30 13:01:36 |
By :
artsurasak |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|