<html> <head> <title>ThaiCreate.Com PHP & MySQL Tutorial</title> </head> <body> <form name="frmSearch" method="post" action="<?=$_SERVER['SCRIPT_NAME'];?>"> <table width="599" border="1"> <tr> <th>Select <select name="ddlSelect" id="ddlSelect"> <option>- Select -</option> <option value="CustomerID" <?if($_POST["ddlSelect"]=="CustomerID"){echo"selected";}?>>CustomerID</option> <option value="Name" <?if($_POST["ddlSelect"]=="Name"){echo"selected";}?>>Name</option> <option value="Email" <?if($_POST["ddlSelect"]=="Email"){echo"selected";}?>>US</option> </select> Keyword <input name="txtKeyword" type="text" id="txtKeyword" value="<?=$_POST["txtKeyword"];?>"> <input type="submit" value="Search"></th> </tr> </table> </form> <? $objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database"); $objDB = mysql_select_db("mydatabase"); // Search By Name or Email $strSQL = "SELECT * FROM customer WHERE 1 "; if($_POST["ddlSelect"] != "" and $_POST["txtKeyword"] != '') { $strSQL .= " AND (".$_POST["ddlSelect"]." LIKE '%".$_POST["txtKeyword"]."%' ) "; } $objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]"); ?> <table width="600" border="1"> <tr> <th width="91"> <div align="center">CustomerID </div></th> <th width="98"> <div align="center">Name </div></th> <th width="198"> <div align="center">Email </div></th> <th width="97"> <div align="center">CountryCode </div></th> <th width="59"> <div align="center">Budget </div></th> <th width="71"> <div align="center">Used </div></th> </tr> <? while($objResult = mysql_fetch_array($objQuery)) { ?> <tr> <td><div align="center"><?=$objResult["CustomerID"];?></div></td> <td><?=$objResult["Name"];?></td> <td><?=$objResult["Email"];?></td> <td><div align="center"><?=$objResult["CountryCode"];?></div></td> <td align="right"><?=$objResult["Budget"];?></td> <td align="right"><?=$objResult["Used"];?></td> </tr> <? } ?> </table> <? mysql_close($objConnect); ?> </body> </html>
<html> <head> <title>ThaiCreate.Com PHP & MySQL Tutorial</title> </head> <body> <form name="frmSearch" method="post" action="<?=$_SERVER['SCRIPT_NAME'];?>"> <table width="599" border="1"> <tr> <th>Select <select name="ddlSelect" id="ddlSelect"> <option>- Select -</option> <option value="CustomerID" <?if($_POST["ddlSelect"]=="CustomerID"){echo"selected";}?>>CustomerID</option> <option value="Name" <?if($_POST["ddlSelect"]=="Name"){echo"selected";}?>>Name</option> <option value="Email" <?if($_POST["ddlSelect"]=="Email"){echo"selected";}?>>US</option> </select> Keyword <input name="txtKeyword" type="text" id="txtKeyword" value="<?=$_POST["txtKeyword"];?>"> <input type="submit" value="Search"></th> </tr> </table> </form> <? $objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database"); $objDB = mysql_select_db("mydatabase"); // Search By Name or Email $strSQL = "SELECT * FROM customer WHERE 1 "; if($_POST["ddlSelect"] != "" and $_POST["txtKeyword"] != '') { $strSQL .= " AND (".$_POST["ddlSelect"]." LIKE '%".$_POST["txtKeyword"]."%' ) "; } $objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]"); ?> <table width="600" border="1"> <tr> <th width="91"> <div align="center">CustomerID </div></th> <th width="98"> <div align="center">Name </div></th> <th width="198"> <div align="center">Email </div></th> <th width="97"> <div align="center">CountryCode </div></th> <th width="59"> <div align="center">Budget </div></th> <th width="71"> <div align="center">Used </div></th> <th>delete</th> </tr> <? while($objResult = mysql_fetch_array($objQuery)) { ?> <tr> <td><div align="center"><?=$objResult["CustomerID"];?></div></td> <td><?=$objResult["Name"];?></td> <td><?=$objResult["Email"];?></td> <td><div align="center"><?=$objResult["CountryCode"];?></div></td> <td align="right"><?=$objResult["Budget"];?></td> <td align="right"><?=$objResult["Used"];?></td> <td><a href='del.php?id=<?=$objResult['CustomerID']?>'>del</a></td> </tr> <? } ?> </table> <? mysql_close($objConnect); ?> </body> </html>
if($_GET['id'] != ''){ $del = mysql_query("DELETE FROM customer WHERE CustomerID='$_GET[id]'"); if($del){ echo "ลบข้อมูลสำเร็จ"; }else{ echo "ลบข้อมูลไม่สำเร็จ"; } }
<!doctype html> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> </head> <body> <p> <form name="frmSearch" method="get" action="<?=$_SERVER['SCRIPT_NAME'];?>"> <table width="599" border="1"> <tr> <th>ค้นหา (กรอกรหัสนักศึกษา,กลุ่มเรียน) <input name="txtKeyword" type="text" id="txtKeyword" value="<?=$_GET["txtKeyword"];?>"> <input type="submit" value="Search"></th> </tr> </table> </form> <? if($_GET["txtKeyword"] != "") { include"dbconnect.php"; $search_std = "select * from tb_student where(STD_GROUP_CODE LIKE '%".$_GET["txtKeyword"]."%' or STUDENT_CODE LIKE '%".$_GET["txtKeyword"]."%' )"; $search1 = mysql_db_query($dbname,$search_std); ?> <table width="100%" border="1"> <tr> <th width="13%"> <div align="center">รหัสบัตรประจำตัวประชาชน </div></th> <th width="5%"> <div align="center">คำนำหน้า </div></th> <th width="10%"> <div align="center">ชื่อ </div></th> <th width="9%"> <div align="center">นามสกุล </div></th> <th width="7%"> <div align="center">รหัสนักศึกษา </div></th> <th width="16%"> <div align="center">คณะ </div></th> <th width="14%"> <div align="center">สาขาวิชา </div></th> <th width="7%"> <div align="center">ภาค </div></th> <th width="7%"> <div align="center">รหัสกลุ่มเรียน </div></th> <th width="7%"> <div align="center">เบอร์โทรศัพท์ </div></th> <th width="2%"> <div align="center">ลบ</div></th> <th width="3%"> <div align="center"></div></th> </tr> <? while($objResult = mysql_fetch_array($search1)) { ?> <tr> <td><div align="center"> <?=$objResult["CITIZEN_ID"];?> </div></td> <td><div align="center"> <?=$objResult["PREFIX_NAME"];?> </div></td> <td><div align="left"> <?=$objResult["STD_FNAME"];?> </div></td> <td><div align="left"> <?=$objResult["STD_LNAME"];?> </div></td> <td><div align="center"> <?=$objResult["STUDENT_CODE"];?> </div></td> <td><div align="center"> <?=$objResult["FACULTY_NAME"];?> </div></td> <td><div align="center"> <?=$objResult["PROGRAM_NAME"];?> </div></td> <td><div align="center"> <?=$objResult["SECTION_NAME"];?> </div></td> <td><div align="center"> <?=$objResult["STD_GROUP_CODE"];?> </div></td> <td><div align="center"> <?=$objResult["TELEPHONE"];?> </div></td> <td align="center"><a href="delete.php?id=<?=$objResult["STUDENT_CODE"];?>">Delete</a></td> <td align="right"> </td> </tr> <? } ?> </table> <? mysql_close; } ?> </p> </body> </html>
<? include"dbconnect.php"; $strSQL = "DELETE FROM tb_student "; $strSQL .="WHERE STUDENT_CODE = '".$_GET["id"]."' "; $objQuery = mysql_query($strSQL); if($objQuery) { echo "Record Deleted."; } else { echo "Error Delete [".$strSQL."]"; } ?>
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง