<?php $objConnect = mysql_connect("localhost","root","12345678") or die("Error Connect to Database"); $objDB = mysql_select_db("project"); //*** Delete Condition ***// if($_GET["Action"] == "Del") { $strSQL = "DELETE FROM tb_com where sn_com = '".$_GET["sn_com"]."'"; $objQuery = mysql_query($strSQL); if(!$objQuery) { echo "Error Delete [".mysql_error()."]"; } //header("location:$_SERVER[PHP_SELF]"); //exit(); } ?> </table> </td> <td width="1042" colspan="2" align="center" valign="top"><h5>ลบเครื่องคอมพิวเตอร์ห้อง 4705</h5> <table width="720" border="1"> <?php $objConnect = mysql_connect("localhost","root","12345678") or die("Error Connect to Database"); $objDB = mysql_select_db("project"); $strSQL = "SELECT * FROM tb_com where id_room ='4705' order by id_image asc "; $objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]"); ?> <tr> <th width="100"><div align="center">รหัสเครื่องคอมพิวเตอร์</div></th> <th width="100"><div align="center">แถว</div></th> <th><div align="center">C1</div></th> <th><div align="center">C2</div></th> <th><div align="center">C3</div></th> <th><div align="center">C4</div></th> <th><div align="center">C5</div></th> <th><div align="center">C6</div></th> <th><div align="center">C7</div></th> <th><div align="center">C8</div></th> <th><div align="center">C9</div></th> <th><div align="center">C10</div></th> <th><div align="center">C11</div></th> <th><div align="center">C12</div></th> <th><div align="center">C13</div></th> <th><div align="center"></div></th> </tr> <?php while($objResult = mysql_fetch_array($objQuery)) { ?> <tr> <td width="100"><?=$objResult["sn_com"];?></td> <td width="100"><?=$objResult["id_image"];?></td> <td><?=$objResult["c1"];?></td> <td><?=$objResult["c2"];?></td> <td><?=$objResult["c3"];?></td> <td><?=$objResult["c4"];?></td> <td><?=$objResult["c5"];?></td> <td><?=$objResult["c6"];?></td> <td><?=$objResult["c7"];?></td> <td><?=$objResult["c8"];?></td> <td><?=$objResult["c9"];?></td> <td><?=$objResult["c10"];?></td> <td><?=$objResult["c11"];?></td> <td><?=$objResult["c12"];?></td> <td><?=$objResult["c13"];?></td> <td><a href="JavaScript:if(confirm('ยืนยันการลบ?')==true){window.location='<?php echo $_SERVER["PHP_SELF"];?>?Action=Del&sn_com=<?php echo $objResult["sn_com"];?>';}" class="btn btn-danger btn-sm">ลบ</a></td> </tr> <?php } ?>
ไม่น่ายาก 1. SELECT * FROM tb_com where sn_com= ' $objResult["sn_com"]' 2. num_row 3. If else เมื่อมี ให้ DELETE FROM tb_com where sn_com = '".$_GET["sn_com"]."' และ Delete image 4. update 5. จบ ครับ 6. ทำภายใน if else {}
update c , i set c.c13=null, i.idroom=null from tb_com c , tb_image i where c.xxx = i.xxx and c.yyy = i.yyy
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง