SELECT * FROM `table` WHERE `birthday` BETWEEN CONCAT(2550 - 60, '-07-01') # ตั้งแต่วันที่ 1 เดือน 7 ของปี -60 AND CONCAT(2550 - 59, '-06-30') # จนถึงวันที่ 30 เดือน 6 ของปี -59
SELECT * FROM ob WHERE birth BETWEEN CONCAT(1999- 60, '-07-01') AND CONCAT(1999 - 59, '-06-30')
$year = $_POST['year'];//2550 $year = $year - 543;//แปลงเป็น ค.ศ. 2007 $year1 = ($year - 60);//1947 $year2 = ($year - 59);//1948 $start1 = $year1.'-07-01';// 1947-07-01 $end1 = $year1.'-12-31';// 1947-12-31 $start2 = $year2.'-01-01';// 1948-01-01 $end2 = $year2.'-06-30';// 1948-06-30 $sql = "SELECT * FROM ob WHERE (birth BETWEEN '$start1' AND '$end2') ";
<html> <head> <title></title> <style type="text/css"> .style1 {font-size: xx-large; font-weight: bold; } </style> <meta http-equiv="Content-Type" content="text/html; charset=windows-874"> <style type="text/css"> body { background-image: url(Old-Paper-Background-520x346.jpg); } </style> </head> <body> <? include("menu.php"); ?> <form name="frmSearch" method="get" action="<?=$_SERVER['SCRIPT_NAME'];?>"> <table width="865" border="1" align="center"> <tr> </tr> </table> <table width="599" border="1" align=center> <tr> <th>ค้นหาโดยกรอกวันเกิด <input name="txtKeyword" type="text" id="txtKeyword" value="<?=$_GET["txtKeyword"];?>"> <input type="submit" value="Search"></th> </tr> </table> </form> <? if($_GET["txtKeyword"] != "") { $objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database"); $objDB = mysql_select_db("police_mamber"); mysql_query("SET character_set_results=tis620"); mysql_query("SET character_set_client=tis620"); mysql_query("SET character_set_connection=tis620"); **************************************************************************** $year = $_POST['year']; $year = $year - 543;//แปลงเป็น ค.ศ. 2007 $year1 = ($year - 60);//1947 $year2 = ($year - 59);//1948 $start1 = $year1.'-07-01';// 1947-07-01 $end1 = $year1.'-12-31';// 1947-12-31 $start2 = $year2.'-01-01';// 1948-01-01 $end2 = $year2.'-06-30';// 1948-06-30 $strSQL = "SELECT * FROM ob WHERE (birth BETWEEN '$start1' AND '$end2') "; **************************************************************************** $id=$result["id"]; $objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]"); ?> <center><table width="800" border="1"> <tr> <td><table width="800" border="1" align=center>s <tr> <th width="70" bgcolor="#EEEEEE"> <div align="center">ลำดับที่ </div></th> <th width="120" bgcolor="#EEEEEE"> <div align="center">รหัสประชาชน </div></th> <th width="20" bgcolor="#EEEEEE"> <div align="center">ยศ</div></th> <th width="60" bgcolor="#EEEEEE"> <div align="center">เพศ</div></th> <th width="150" bgcolor="#EEEEEE"> <div align="center">ขื่อ</div></th> <th width="150" bgcolor="#EEEEEE"> <div align="center">นามสกุล</div></th> <th width="50" bgcolor="#EEEEEE"> <div align="center">เลือก</div></th> </tr> <? while($objResult = mysql_fetch_array($objQuery)) { ?> <tr> <td bgcolor="#EEEEEE"><?=$objResult["id"];?></td> <td bgcolor="#EEEEEE"><?=$objResult["idpeople"];?></td> <td bgcolor="#EEEEEE"><?=$objResult["rank"];?></td> <td bgcolor="#EEEEEE"><?=$objResult["sex"];?> </div></td> <td bgcolor="#EEEEEE" ><?=$objResult["name"];?></td> <td bgcolor="#EEEEEE" ><?=$objResult["lastname"];?></td> <td ><?=displaydate($objResult["birth"]);?></td> <td ><?=$y;?></td> <td bgcolor="#EEEEEE"><a href='dbpoliceshow.php?id=<?php echo $objResult["id"]; ?>',<?=$objResult["FilesID"];?>>edit</a> </center> </tr> <? } ?> </table></td> </tr> </table> <? mysql_close($objConnect); } ?> </body> </html>
$year = $_GET['txtKeyword'];
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง