<html> <head> <title>ThaiCreate.Com PHP & MySQL Tutorial</title> </head> <body> <? include "config.in.php"; $ProID=$_GET["ProID"] ; $StuID=$_GET["StuID"] ; $Project_Name=$_GET["Project_Name"] ; if($_GET["Action"] == "Update") { $strSQL = "UPDATE project SET Project_Name =$Project_Name where Project_ID =$ProID"; $objQuery = mysql_query($strSQL); if(!$objQuery) { echo "Error Update [".mysql_error()."]"; } } if($_GET["Action"] == "Del") { $strSQL = "DELETE FROM project WHERE Project_ID=$ProID "; $objQuery = mysql_query($strSQL); if(!$objQuery) { echo "Error Delete [".mysql_error()."]"; } } $strSQL = "SELECT project. * , student.Student_ID FROM project, student WHERE project.Project_ID = student.Project_ID AND project.Project_ID >0"; $objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]"); ?> <form name="formadd" method="post" action="<?=$_SERVER["PHP_SELF"];?>"> <input type="hidden" name="hdnPro" value=""> <table width="600" border="1"> <tr> <th width="91"> <div align="center">CustomerID </div></th> <th colspan="5"> <div align="center">Name </div></th> <th width="30"> <div align="center">Edit </div></th> <th width="30"> <div align="center">Delete </div></th> </tr> <? while($objResult = mysql_fetch_array($objQuery)) { ?> <? if($objResult["Project_ID"] == $_GET["ProID"] and $_GET["Action"] == "Edit") { ?> <tr> <td><div align="center"> <?=$objResult["Project_ID"];?> <input type="hidden" name="hdnProID" size="5" value="<?=$objResult["Project_ID"];?>"> </div></td> <td colspan="5"><input type="text" name="Project_Name" size="20" value="<?=$objResult["Project_Name"];?>"></td> <td colspan="2" align="right"><div align="center"> <input name="btnAdd" type="button" id="btnUpdate" value="Update" OnClick="formadd.hdnProID.value='Update';formadd.submit();"> <input name="btnAdd" type="button" id="btnCancel" value="Cancel" OnClick="window.location='<?=$_SERVER["PHP_SELF"];?>';"> </div></td> </tr> <? } else { ?> <tr> <td><div align="center"><?=$objResult["Project_ID"];?></div></td> <td colspan="5"><?=$objResult["Project_Name"];?></td> <td align="center"><a href="<?=$_SERVER["PHP_SELF"];?>?Action=Edit&ProID=<?=$objResult["Project_ID"];?>&StuID<?=$objResult["Student_ID"];?>">Edit</a></td> <td align="center"><a href="JavaScript:if(confirm('Confirm Delete?')==true){window.location='<?=$_SERVER["PHP_SELF"];?>?Action=Del&ProID=<?=$objResult["Project_ID"];?>&StuID<?=$objResult["Student_ID"];?>';}">Delete</a></td> </tr> <? } ?> <? } ?> <tr> </tr> </table> </form> </body> </html>
"UPDATE project SET Project_Name =$Project_Name where Project_ID =$ProID";
Echo $_GET[Action];
<? include "config.in.php"; $ProID=$_GET["ProID"] ; $StuID=$_GET["StuID"] ; $Project_Name=$_POST["Project_Name"] ; if($_GET["Action"] == "Update") { $strSQL = "UPDATE project SET Project_Name ='$Project_Name' where Project_ID='$ProID'"; $objQuery = mysql_query($strSQL); if(!$objQuery) { echo "Error Update [".mysql_error()."]"; } header("location:$_SERVER[PHP_SELF]"); exit(); } if($_GET["Action"] == "Del") { $strSQL1 = "DELETE FROM project WHERE Project_ID=$ProID AND Student_ID = $StuID "; $query1 = mysql_query($strSQL1) or die('Error Delete ['.mysql_error().']'); $strSQL2="UPDATE student SET Project_ID=0 WHERE Student_ID=$StuID"; $objQuery = mysql_query($strSQL2); if(!$objQuery) { echo "Error UPDATE [".mysql_error()."]"; } header("location:$_SERVER[PHP_SELF]"); exit(); } ?> <form id="form1" method="post" action=""> <table width="100%" border="0"> <tr> <td align="center"> <span class="style1">ค้นจาก <select name="by" class="style1" id="by"> <option value="Project_Name" selected="selected">ชื่อโครง</option> <option value="Proect_Term ">ภาคเรียน</option> </select> </span> <span class="style1">คำที่ใช้ค้นหา</span> <input type="text" name="keyword" id="keyword" /> <input name="button" type="submit" class="style1" id="button" value=" ค้นหาชื่อโครงงาน " /></td> </tr> </table> </form> <? if($keyword==""){ $strSQL="SELECT project. * , student.Student_ID FROM project, student WHERE project.Project_ID = student.Project_ID AND project.Project_ID >0"; }else{ $strSQL="SELECT project. * , student.Student_ID FROM project, student WHERE project.Project_ID = student.Project_ID AND project.Project_ID >0 AND $by like '%$keyword%' "; } $objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]"); $Num_Rows = mysql_num_rows($objQuery); $Per_Page = 10; // Per Page $Page = $_GET["Page"]; if(!$_GET["Page"]) { $Page=1; } $Prev_Page = $Page-1; $Next_Page = $Page+1; $Page_Start = (($Per_Page*$Page)-$Per_Page); if($Num_Rows<=$Per_Page) { $Num_Pages =1; } else if(($Num_Rows % $Per_Page)==0) { $Num_Pages =($Num_Rows/$Per_Page) ; } else { $Num_Pages =($Num_Rows/$Per_Page)+1; $Num_Pages = (int)$Num_Pages; } $strSQL .=" order by Project_Year ASC LIMIT $Page_Start , $Per_Page"; $objQuery = mysql_query($strSQL); ?> <form name="formadd" method="post" action="<?=$_SERVER["PHP_SELF"];?>"> <input type="hidden" name="hdnPro" value=""> <table width="600" border="1" align="center"> <tr> <th width="91"> <div align="center">CustomerID </div></th> <th colspan="5"> <div align="center">Name </div></th> <th width="30"> <div align="center">Edit </div></th> <th width="30"> <div align="center">Delete </div></th> </tr> <? while($objResult = mysql_fetch_array($objQuery)) { ?> <? if($objResult["Project_ID"] == $_GET["ProID"] and $_GET["Action"] == "Edit") { ?> <tr> <td><div align="center"> <?=$objResult["Project_ID"];?> <input type="hidden" name="hdnProID" size="5" value="<?=$objResult["Project_ID"];?>"> </div></td> <td colspan="5"><input type="text" name="Project_Name" size="20" value="<?=$objResult['Project_Name'];?>"></td> <td colspan="2" align="right"><div align="center"> <input name="btnAdd" type="button" id="btnUpdate" value="Update" OnClick="formadd.hdnProID.value='Update';formadd.submit();"> <input name="btnAdd" type="button" id="btnCancel" value="Cancel" OnClick="window.location='<?=$_SERVER["PHP_SELF"];?>';"> </div></td> </tr> <? } else { ?> <tr> <td><div align="center"><?=$objResult["Project_ID"];?></div></td> <td colspan="5"><?=$objResult["Project_Name"];?></td> <td align="center"><a href="<?=$_SERVER["PHP_SELF"];?>?Action=Edit&ProID=<?=$objResult["Project_ID"];?>&StuID<?=$objResult["Student_ID"];?>">Edit</a></td> <td align="center"><a href="JavaScript:if(confirm('Confirm Delete?')==true){window.location='<?=$_SERVER["PHP_SELF"];?>?Action=Del&ProID=<?=$objResult["Project_ID"];?>&StuID<?=$objResult["Student_ID"];?>';}">Delete</a></td> </tr> <? } ?> <? } ?> <tr> </tr> </table> <div align="center"><br> <span class="style1">ทั้งหมด <span class="style12"> <?= $Num_Rows;?> </span> จำนวนหน้า : <span class="style14"> <?=$Num_Pages;?> </span> หน้า : <strong> <? if($Prev_Page) { echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page'><< กลับ</a> "; } for($i=1; $i<=$Num_Pages; $i++){ if($i != $Page) { echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i'>$i</a> ]"; } else { echo "<b> $i </b>"; } } if($Page!=$Num_Pages) { echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page'>ถัดไป>></a> "; } ?> </div> </form>
include "config.in.php"; $ProID=$_GET["ProID"] ; $Project_Name=$_GET["Project_Name"] ; if($_GET["Action"] == "Update_id") { $strSQL = "UPDATE project SET Project_Name ='$Project_Name' where Project_ID='$ProID'"; $objQuery = mysql_query($strSQL); if(!$objQuery) { echo "Error Update [".mysql_error()."]"; } echo "ค่า Action =".$Action."<br>"; echo "ค่า ID =".$ProID."<br>"; echo "ค่า Project_Name =".$Project_Name."<br>"; /*header("location:$_SERVER[PHP_SELF]"); exit();*/ }
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง