Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > สอบถาม เรื่องการเชื่อมต่อหน้า และการส่งค่าจาก php ไปแสดงที่หน้า html อีกหน้า



 

สอบถาม เรื่องการเชื่อมต่อหน้า และการส่งค่าจาก php ไปแสดงที่หน้า html อีกหน้า

 



Topic : 112202



โพสกระทู้ ( 19 )
บทความ ( 0 )



สถานะออฟไลน์




คือตอนนี้ ผมมีหน้า html

html

คือเมื่อใส่ข้อมูลที่หน้านี้ แล้วมันจะไปประมวลผลที่หน้า php อีกหน้า

แล้วผมอยากนำค่าที่ประมวลผลจาก php มาแสดงที่หน้า html อีกหน้านึง ให้ออกเป็นตารางอย่างนี้

html

มันต้องเชื่อมหน้ากันยังไงอ่ะครับ หรือมีวิธีไหนที่ง่ายกว่านี้ แนะนำหน่อยครับ

พอดีผมเพิ่งเริ่มเขียน



Tag : PHP







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2014-10-28 14:30:25 By : artsurasak View : 2278 Reply : 3
 

 

No. 1



โพสกระทู้ ( 2,249 )
บทความ ( 5 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook Hi5 Blogger

แบบนี้ คงต้องใช้เทคนิค Ajax แล้วครับผม ลองดูครับ

jquery-ajax-ajax






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-10-28 14:32:58 By : Manussawin
 


 

No. 2



โพสกระทู้ ( 74 )
บทความ ( 0 )



สถานะออฟไลน์


อันนี้ผมไม่แน่ใจว่า จขกท ต้องการให้นำค่าที่ได้จาก php มาแสดงที่หน้า html เดิม หรือ html หน้าใหม่นะครับ ซึ่งทั้ง 2 แบบก็มีวิธีเหมือนกันครับ

1. ถ้าต้องการนำค่าที่ประมวลผลจาก php มาแสดงในหน้า html เดิม ก็ใช้ Ajax ครับ
https://www.thaicreate.com/tutorial/ajax-method-post.html

2. ถ้าต้องการนำค่าที่ประมวลผลจาก php มาแสดงในหน้า html ใหม่ ก็ใช้การ post form แบบธรรมดาก็ได้ครับ
https://www.thaicreate.com/php/php-html-form.html
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2014-10-29 17:59:34 By : Pangpondpuen
 

 

No. 3



โพสกระทู้ ( 19 )
บทความ ( 0 )



สถานะออฟไลน์


คือแบบนี้อ่ะครับ

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
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : สอบถาม เรื่องการเชื่อมต่อหน้า และการส่งค่าจาก php ไปแสดงที่หน้า html อีกหน้า
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 05
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่