<? mysql_connect("localhost","root","1234"); mysql_select_db("travel"); $charset="SET NAMES 'utf8' "; mysql_query($charset); ?> <script language="javascript"> function fncCreateSelectOption(ele) { var objSelect = ele; var Item = new Option("<-- Please Select -->"); objSelect.options[objSelect.length] = Item; <? $strSQL = "SELECT Travel_name FROM travel_detail UNION ALL SELECT food_name FROM food UNION ALL SELECT hotel_name FROM hotel"; $objQuery = mysql_query($strSQL); while($objResult = mysql_fetch_array($objQuery)) { ?> var Item = new Option("<?=$objResult["Travel_name"];?>"); objSelect.options[objSelect.length] = Item; <? } ?> } function fncCreateElement(){ var mySpan = document.getElementById('mySpan'); var myElement1 = document.createElement('select'); myElement1.setAttribute('id',"toPlace"); myElement1.setAttribute('name',"toPlace"); mySpan.appendChild(myElement1); fncCreateSelectOption(myElement1); } </script> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml"> <head> <title>Google Maps JavaScript API Example: Simple Directions</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> </head> <body onload="initialize()"> <div id="map_canvas" style="width: 70%; height: 480px; float:left; border: 1px solid black;"></div> <div id="route" style="width: 25%; height:480px; float:right; border; 1px solid black;"></div> <table width="800" border="0" > <tr> <td align="center" height="30"> <form name="road" method="post" action="" > From: <select name="namePlace" id="namePlace" onchange="return check();" > <option value="99"><-- Please Select --></option> <? $strSQL = "SELECT Travel_name FROM travel_detail UNION ALL SELECT food_name FROM food UNION ALL SELECT hotel_name FROM hotel"; $objQuery = mysql_query($strSQL); while($objResuut = mysql_fetch_array($objQuery)) { ?> <option value="<? echo $objResuut["Travel_name"]; ?>"><? echo $objResuut["Travel_name"];?></option> <? } ?> </select> To: <select name="toPlace" id="toPlace" onchange="return check();" > <option value=""><-- Please Select --></option> <? $strSQL1 = "SELECT Travel_name FROM travel_detail UNION ALL SELECT food_name FROM food UNION ALL SELECT hotel_name FROM hotel"; $objQuery1 = mysql_query($strSQL1); while($objResuut1 = mysql_fetch_array($objQuery1)) { ?> <option value="<? echo $objResuut1["Travel_name"];?>"><? echo $objResuut1["Travel_name"];?></option> <? } ?> </select> <span id="mySpan"> </span> <input name="btnButton" id="btnButton" type="button" value="+" onClick="JavaScript:fncCreateElement();"> <input type="submit" name="SearchPlace" id="SearchPlace" value="Search" onclick="return check();" /> <input type="button" name="iClear" id="iClear" value="Clear" /> </form> </td> </tr> </table> <? $ch = mysql_query("SELECT * FROM travel_detail WHERE Travel_name = '".$_POST['namePlace']."' "); $chrow = mysql_num_rows($ch); $ch2 = mysql_query("SELECT * FROM food WHERE food_name = '".$_POST['namePlace']."' "); $chrow2 = mysql_num_rows($ch2); $ch3 = mysql_query("SELECT * FROM hotel WHERE hotel_name = '".$_POST['namePlace']."' "); $chrow3 = mysql_num_rows($ch3); if($chrow !=0){ //เริ่มต้นสถานที่ท่องเที่ยว $strSQL1 = "SELECT * FROM travel_detail WHERE Travel_name = '".$_POST["namePlace"]."' "; $objQuery1 = mysql_query($strSQL1); $objResult2 = mysql_fetch_array($objQuery1); echo "<br>"; echo "From: "; echo $objResult2["Travel_name"]; $to = mysql_query("SELECT * FROM travel_detail WHERE Travel_name = '".$_POST['toPlace']."' "); $torow = mysql_num_rows($to); $to2 = mysql_query("SELECT * FROM food WHERE food_name = '".$_POST['toPlace']."' "); $torow2 = mysql_num_rows($to2); $to3 = mysql_query("SELECT * FROM hotel WHERE hotel_name = '".$_POST['toPlace']."' "); $torow3 = mysql_num_rows($to3); if($torow !=0){ //ปลายทางสถานที่ท่องเที่ยว $strSQL11 = "SELECT * FROM travel_detail WHERE Travel_name = '".$_POST["toPlace"]."' "; $objQuery11 = mysql_query($strSQL11); $objResult12 = mysql_fetch_array($objQuery11); echo " to: "; echo $objResult12["Travel_name"]; } else if($torow2 !=0){ //ปลายทาง ร้านอาาหาร $strSQL11 = "SELECT * FROM food WHERE food_name = '".$_POST["toPlace"]."' "; $objQuery11 = mysql_query($strSQL11); $objResult12 = mysql_fetch_array($objQuery11); //echo "<br>"; echo "to: "; echo $objResult1["lati"]; echo ","; echo $objResult1["long"]; echo" "; echo " to: "; echo $objResult12["food_name"]; } else if($torow3 !=0){ //ปลายทางที่พัก $strSQL11 = "SELECT * FROM hotel WHERE hotel_name = '".$_POST["toPlace"]."' "; $objQuery11 = mysql_query($strSQL11); $objResult12 = mysql_fetch_array($objQuery11); //echo "<br>"; echo "to: "; echo $objResult1["lati"]; echo ","; echo $objResult1["long"]; echo" "; echo " to: "; echo $objResult12["hotel_name"]; } } ?> <br/> </body> </html>
myElement1.setAttribute('name',"toPlace_Plus[]");
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง